Pass JSON object with error 401
brunosiqueira opened this issue · 1 comments
brunosiqueira commented
I am struggling a little understanding this. I am using LocalStrategy to authenticate android users. I want to send to the cliente, the message information, but it is not getting received by the client response. Not sure if I understood the documentation wrong.
passport.use(new LocalStrategy({ passReqToCallback: true },
function(req, username, password, done) {
db.user.find({ where : { username : username}}).then(function(user) {
if (!user) {
return done(null, false, {message: 'incorrect_password'});
}
user.validatePassword(password, function(valid) {
if (!valid ) return done(null, false);
if ( req.body.scope && req.body.scope.indexOf('admin') > -1 && !user.isAdmin ) {
return done(null, false, {message: 'no_permission'});
}
if (!user.isEnabled){
return done(null, false, {message: 'not_enabled'});
}
return done(null, user);
});
});
}
));
yocontra commented
It is passing the info object up to passport https://github.com/jaredhanson/passport-local/blob/master/lib/strategy.js#L82
So it seems like the issue is that passport.Strategy is not taking the object passed to fail and serving it