improving tokenAuth messages

parent 473effa0
Showing with 6 additions and 3 deletions
......@@ -32,14 +32,17 @@ module.exports = function(req, res, next) {
//
sailsTokenAuth.verifyToken(token, function(err, token) {
if (err) {
if (err.name == 'TokenExpiredError')
res.json(401, {
if (err.name == 'TokenExpiredError') {
return res.json(401, {
message: 'Invalid token',
name: 'TOKEN_EXPIRED',
code: sails.config.pictogram.error_codes.TOKEN_EXPIRED
});
} else {
return res.json(401, {message: 'Invalid token: ' + err.message});
}
}
if (err) return res.json(401, {message: 'Invalid token'});
req.token = token;
next();
});
......
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