issue #949 fixed

parent 9a096121
...@@ -31,7 +31,15 @@ module.exports = function(req, res, next) { ...@@ -31,7 +31,15 @@ module.exports = function(req, res, next) {
// We have a token, let's verify and decode it // We have a token, let's verify and decode it
// //
sailsTokenAuth.verifyToken(token, function(err, token) { sailsTokenAuth.verifyToken(token, function(err, token) {
if (err) return res.json(401, {err: 'Invalid token ' + token}); if (err) {
if (err.name == 'TokenExpiredError')
res.json(401, {
message: 'Invalid token',
name: 'TOKEN_EXPIRED',
code: sails.config.pictogram.error_codes.TOKEN_EXPIRED
});
}
if (err) return res.json(401, {message: 'Invalid token');
req.token = token; req.token = token;
next(); next();
}); });
......
...@@ -115,6 +115,7 @@ module.exports.pictogram = { ...@@ -115,6 +115,7 @@ module.exports.pictogram = {
'DUPLICATED_PICTO': 1, 'DUPLICATED_PICTO': 1,
'OFFICE_NOT_FOUND': 2, 'OFFICE_NOT_FOUND': 2,
'SUPERVISOR_NOT_FOUND': 3, 'SUPERVISOR_NOT_FOUND': 3,
'STUDENT_NOT_FOUND': 4 'STUDENT_NOT_FOUND': 4,
'TOKEN_EXPIRED': 5
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment