Better handling of invalid tokens

This commit is contained in:
Daniel Brendel
2024-10-03 15:23:41 +02:00
parent 327a2ed302
commit 44cdecb01a
+10 -1
View File
@@ -17,7 +17,16 @@ class ApiController extends BaseController {
$token = $_POST['token'];
}
ApiModel::validateKey($token);
try {
ApiModel::validateKey($token);
} catch (\Exception $e) {
http_response_code(403);
header('Content-Type: application/json');
exit(json([
'code' => 403,
'invalid_token' => $token
])->out(true));
}
}
/**