Files
nat-as-server/handlers/logout.php

19 lines
366 B
PHP

<?php
if ($method !== 'DELETE' && $method !== 'POST') {
json_error('METHOD_NOT_ALLOWED', 'Method not allowed', 405);
}
$token = get_bearer_token();
if (!$token) {
json_error('UNAUTHORIZED', 'Missing Bearer token', 401);
}
try {
token_revoke($token);
} catch (Throwable $e) {
qdb_handler_fail($e, 'Logout');
}
json_success(['loggedOut' => true]);