blob: 179afe68999fbcf0177f60a483b5069b52c15a96 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
namespace Controller;
use Database;
use Exception;
function on_post() {
global $user_status;
global $token;
$user_status = "";
try {
$user = Database\User::fromDB($_POST["username"]);
if (password_verify($_POST["password"], $user->Password)) {
$token = Database\Cookie::create($user->UID);
}
else {
$user_status = "Incorrect password!";
}
}
catch(Exception $e) {
$user_status = "User \"" . $_POST["username"] . "\" doesn't exist!";
}
}
function on_delete() {
global $TOKEN;
try {
Database\Cookie::delete($TOKEN);
}
catch(Exception $e) {}
}
|