File "api-auth-token.inc.php"
Full Path: /srv/www/www.cadoro.it/src/controllers/api-auth-token.inc.php
File size: 692 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: text/json; charset="UTF-8"');
# POST
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$data = _json(file_get_contents('php://input'));
$token = _a($data, 'token');
$user = User::identify($token);
if ($user && $user['active']) {
$user = $user;
} else {
$user = null;
}
# JSON output
echo json_encode(array(
"user" => $user ? $user->json(true) : null,
));
}
# DEFAULT
else {
header('HTTP/1.0 400 Bad Request', true, 400);
header("Content-Type: application/json; charset=utf-8");
echo json_encode(array("error" => "unsupported method"));
}
?>