Better Errors
This commit is contained in:
@@ -16,17 +16,17 @@ class AdminAuth implements IMiddleware
|
||||
|
||||
// No token
|
||||
if ($token === null) {
|
||||
Response::response()->httpCode(401)->json(["message" => "Not Authorized"]);
|
||||
Response::response()->httpCode(401)->json(["code" => "Unauthorized", "message" => "Not Authorized"]);
|
||||
}
|
||||
|
||||
try {
|
||||
$user = User::getByToken($token);
|
||||
if (!$user->getIsAdmin()) {
|
||||
Response::response()->httpCode(401)->json(["message" => "Not Authorized"]);
|
||||
Response::response()->httpCode(401)->json(["code" => "Unauthorized", "message" => "Not Authorized"]);
|
||||
}
|
||||
} catch (Exception $err) {
|
||||
// No user with this token exists
|
||||
Response::response()->httpCode(401)->json(["message" => "Not Authorized"]);
|
||||
Response::response()->httpCode(401)->json(["code" => "Unauthorized", "message" => "Not Authorized"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user