passport js missing credentials
I see your req.body
contains {password: 'password', email: '[email protected]'}
. email
is not what passportjs is looking for, but username
is. You can either change your input names on your HTML/JS, or you can change the default parameters passportjs is looking for in req.body
. You need to apply these changes where you define your strategy.
passport.use(new LocalStrategy({ // or whatever you want to use
usernameField: 'email', // define the parameter in req.body that passport can use as username and password
passwordField: 'password'
},
function(username, password, done) { // depending on your strategy, you might not need this function ...
// ...
}
));
In Router.post:
router.post('/', passport.authenticate('local-signup', {
successRedirect: '/dashboad',
failureRedirect: '/',
badRequestMessage: 'Your message you want to change.', //missing credentials
failureFlash: true
}, function(req, res, next) {
...