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 posted this on Stackoverflow, but thought I might have more luck here:
I was hoping to utilize the custom callback to handle both successes and failures for logins in Passport's authenticate local strategy, but it looks like it's only called on success.
Here is a snippet of what I'm talking about:
passport.use(new LocalStrategy(
{usernameField: 'email', passwordField: 'password'},
function(email, password, done) {
if(canLogin) done(null, user);
else done({message: "This is an error message" }, false, { message: "Some Info" });
}
));
app.post('/login', function(req, res, next) {
passport.authenticate('local', function(err, user, info) {
// Only called if err is not set
res.send("Hello");
});
The docs imply that passport.authenticate allows the error object to trickle down and be handled by the callback, but the above shows otherwise. Am I interpreting this incorrectly?
The text was updated successfully, but these errors were encountered:
I posted this on Stackoverflow, but thought I might have more luck here:
I was hoping to utilize the custom callback to handle both successes and failures for logins in Passport's authenticate local strategy, but it looks like it's only called on success.
Here is a snippet of what I'm talking about:
From the client, using a bad input:
> curl -d "username=bad&password=input" "http://myurl"
Returns
> [Object object]
A 'good' input returns "Hello."
The docs imply that passport.authenticate allows the error object to trickle down and be handled by the callback, but the above shows otherwise. Am I interpreting this incorrectly?
The text was updated successfully, but these errors were encountered: