mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-10 13:18:48 +00:00
cleaned up errors
This commit is contained in:
parent
01e703e538
commit
dee6a19e51
3 changed files with 51 additions and 18 deletions
|
@ -36,8 +36,20 @@ export function authenticateToken() {
|
|||
if (err) {
|
||||
if (err instanceof TokenExpiredError)
|
||||
// check if the error is expired and return 401
|
||||
res.status(401).json({ message: "Token expired" });
|
||||
else res.status(403).json({ message: "Invalid token" });
|
||||
res
|
||||
.status(401)
|
||||
.json({
|
||||
error: "Token expired",
|
||||
details: [{ message: "Token expired" }],
|
||||
});
|
||||
// if the token is invalid, return 403 Forbidden
|
||||
else
|
||||
res
|
||||
.status(403)
|
||||
.json({
|
||||
error: "Invalid token",
|
||||
details: [{ message: "Invalid token" }],
|
||||
});
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue