Updated calls for user session

Users token session must be set for calls to work
This commit is contained in:
cp6 2021-03-17 11:33:54 +11:00
parent 5fafca6dd4
commit c435d43137

View File

@ -2,8 +2,10 @@
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
require_once('class.php');
$auth = new auth();
$auth->sessionStartIfNone();
if (isset($_SESSION['token'])) {
$idle = new idlers();
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($_GET['type'])) {
if ($_GET['type'] == 'server') {
@ -98,3 +100,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
die();
}
}
} else {
header('HTTP/1.1 401 Unauthorized');
echo json_encode(array(
'code' => 401,
'message' => 'Unauthorized'));
exit;
}