Add token expired msg
This commit is contained in:
1 parent
ef4bfec3f2
commit
4a3636789e
2 files changed
+8
-1
No files matched your search
@@ -38,6 +38,11 @@ const verifyJWT = (req, res, next) => {
|
|||||||
const { jwtSecret } = req.settingsService.getSettings();
|
const { jwtSecret } = req.settingsService.getSettings();
|
||||||
jwt.verify(parsedToken, jwtSecret, (err, decoded) => {
|
jwt.verify(parsedToken, jwtSecret, (err, decoded) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (err.name === "TokenExpiredError") {
|
||||||
|
res
|
||||||
|
.status(401)
|
||||||
|
.json({ success: false, msg: errorMessages.EXPIRED_AUTH_TOKEN });
|
||||||
|
}
|
||||||
return res
|
return res
|
||||||
.status(401)
|
.status(401)
|
||||||
.json({ success: false, msg: errorMessages.INVALID_AUTH_TOKEN });
|
.json({ success: false, msg: errorMessages.INVALID_AUTH_TOKEN });
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const errorMessages = {
|
|||||||
UNKNOWN_SERVICE: "Unknown service",
|
UNKNOWN_SERVICE: "Unknown service",
|
||||||
NO_AUTH_TOKEN: "No auth token provided",
|
NO_AUTH_TOKEN: "No auth token provided",
|
||||||
INVALID_AUTH_TOKEN: "Invalid auth token",
|
INVALID_AUTH_TOKEN: "Invalid auth token",
|
||||||
|
EXPIRED_AUTH_TOKEN: "Token expired",
|
||||||
|
|
||||||
//Ownership Middleware
|
//Ownership Middleware
|
||||||
VERIFY_OWNER_NOT_FOUND: "Document not found",
|
VERIFY_OWNER_NOT_FOUND: "Document not found",
|
||||||
@@ -93,7 +94,8 @@ const successMessages = {
|
|||||||
|
|
||||||
//Maintenance Window Controller
|
//Maintenance Window Controller
|
||||||
MAINTENANCE_WINDOW_CREATE: "Maintenance Window created successfully",
|
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 Operations
|
||||||
PING_SUCCESS: "Success",
|
PING_SUCCESS: "Success",
|
||||||
|
|||||||
Reference in new issue
Block a user