I am trying to integrate passport to my code\'s login form. Client side calling server side works as it should until i call passport.authenticate in the request, 400 Bad Request
Bad Request was thrown by passport for missing access on username and password.
It is checking body and URL query for fields username
and password
. If either is falsy the request is rejected with status 400.
On creating your LocalStrategy you may pass set of options in additional argument to constructor choosing differently named fields using options usernameField
and/or passwordField
. In your particular case this would look like this:
passport.use(new LocalStrategy(
{usernameField:"user-email", passwordField:"user-password"},
function(username, password, done) {
return done(null, false, {message:'Unable to login'})
}
));