blob: 8b640ce7052405547a4cad72d9cdd8ae62c9c18c (
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() {
try {
$headers = apache_request_headers();
Database\Cookie::delete($headers["Authorization"]);
}
catch(Exception $e) {}
}
|