You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a local authentication strategy and I am using the custom callback such as so:
router.post('/create_account',
function (req, res, next) {
passport.authenticate('local-signup', function (err, user, info) {
if (err) {
console.log("error found")
return next(err);
}
//custom callback requires manually creating the session
req.login(user, function (err) {
if (err) {
return next(err)
}
return res.send(200);
});
})(req, res, next);
}
);
However, it seems that if there is an error and I invoke done(error) where error is non-null, in configuration of the strategy, the passport.authenticate's callback never gets called. In other words, I never see the "error found" log. Instead, the error goes straight to my final error handler.
This is how the configuration looks:
passport.use('local-signup', new LocalStrategy({
usernameField: 'email',
passwordField: 'password',
passReqToCallback: true
},
function (req, email, password, done) {
var newUser = new User();
// save the user
newUser.save(function (err) {
if (err) {
//********Assume Error occurs here!*******
return done(err)
}
done(null, newUser);
});
})
);
The text was updated successfully, but these errors were encountered:
I am using a local authentication strategy and I am using the custom callback such as so:
However, it seems that if there is an error and I invoke
done(error)
whereerror
is non-null, in configuration of the strategy, the passport.authenticate's callback never gets called. In other words, I never see the "error found" log. Instead, the error goes straight to my final error handler.This is how the configuration looks:
The text was updated successfully, but these errors were encountered: