tokenAuth error documented

parent c66c1556
......@@ -31,17 +31,8 @@ module.exports = function(req, res, next) {
// We have a token, let's verify and decode it
//
sailsTokenAuth.verifyToken(token, function(err, token) {
if (err) {
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: ' + err.message});
req.token = token;
next();
......
......@@ -111,6 +111,7 @@ module.exports.pictogram = {
}
},
// TODO: errores should have a code (number) and a name (string) like "TokenExpired", "UserNotFound"...
error_codes: {
'DUPLICATED_PICTO': 1,
'OFFICE_NOT_FOUND': 2,
......
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