Add token expired msg

This commit is contained in:
Alex Holliday
2024-10-07 13:54:00 +08:00
parent ef4bfec3f2
commit 4a3636789e
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -38,6 +38,11 @@ const verifyJWT = (req, res, next) => {
const { jwtSecret } = req.settingsService.getSettings();
jwt.verify(parsedToken, jwtSecret, (err, decoded) => {
if (err) {
if (err.name === "TokenExpiredError") {
res
.status(401)
.json({ success: false, msg: errorMessages.EXPIRED_AUTH_TOKEN });
}
return res
.status(401)
.json({ success: false, msg: errorMessages.INVALID_AUTH_TOKEN });
+3 -1
View File
@@ -12,6 +12,7 @@ const errorMessages = {
UNKNOWN_SERVICE: "Unknown service",
NO_AUTH_TOKEN: "No auth token provided",
INVALID_AUTH_TOKEN: "Invalid auth token",
EXPIRED_AUTH_TOKEN: "Token expired",
//Ownership Middleware
VERIFY_OWNER_NOT_FOUND: "Document not found",
@@ -93,7 +94,8 @@ const successMessages = {
//Maintenance Window Controller
MAINTENANCE_WINDOW_CREATE: "Maintenance Window created successfully",
MAINTENANCE_WINDOW_GET_BY_USER: "Got Maintenance Windows by User successfully",
MAINTENANCE_WINDOW_GET_BY_USER:
"Got Maintenance Windows by User successfully",
//Ping Operations
PING_SUCCESS: "Success",