aboutsummaryrefslogtreecommitdiff
path: root/views/profile/authenticate.php
blob: 540d4a3345baec0caae144e9ef32c262552d5e7d (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
<?php

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header('Allow: POST');
    http_response_code(405);
    header('Content-Type: text/plain');
    echo $_SERVER['REQUEST_METHOD'] . " request not allowed!";
    exit;
}

include '../meta.php';

$user = null;
runController('user');

if ($user !== null) {
    http_response_code(200);
    header('Content-Type: text/plain');
    echo $user->Username;
}
else {
    http_response_code(401);
    header('Content-Type: text/plain');
    echo 'Bad token!';
}

exit;