diff options
Diffstat (limited to 'controllers')
| -rw-r--r-- | controllers/login.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/controllers/login.php b/controllers/login.php new file mode 100644 index 0000000..75c62ac --- /dev/null +++ b/controllers/login.php @@ -0,0 +1,20 @@ +<?php + +function on_post() { + global $status; + global $token; + $status = ""; + + try { + $user = Database\User::fromDB($_POST["username"]); + if (password_verify($_POST["password"], $user->Password)) { + $token = Database\Cookie::create($user->UID); + } + else { + $status = "Incorrect password!"; + } + } + catch(Exception $e) { + $status = "User \"" . $_POST["username"] . "\" doesn't exist!"; + } +} |
