Commit 674fa6da by Pablo Molina

Eliminados ficheros innecesarios

parent 30012267
module.exports = function(req, res, next) {
var token;
//
// Token comes in the header
//
if (req.headers && req.headers.authorization) {
var parts = req.headers.authorization.split(' ');
if (parts.length == 2) {
var scheme = parts[0],
credentials = parts[1];
if (/^Bearer$/i.test(scheme)) {
token = credentials;
}
} else {
return res.json(401, {err: 'Format is Authorization: Bearer [token]'});
}
//
// Token comes as a parameter
//
} else if (req.param('token')) {
token = req.param('token');
// We delete the token from param to not mess with blueprints
delete req.query.token;
: } else {
return res.json(401, {err: 'No Authorization header was found'});
}
//
// We have a token, let's verify it
//
sailsTokenAuth.verifyToken(token, function(err, token) {
if (err) return res.json(401, {err: 'Invalid token'});
req.token = token;
next();
});
};
\ No newline at end of file
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