I am working on the login page for Passport NodeJs, Express. I am a web developer, but this is my first NodeJS project.
I follow this guide:
http://mherman.org/blog/2013/11/11/user-authentication-with-passport-dot-js/
But every time I try to enter the login page or the registration page, the only thing I have is the Bad Request page.
I called back to find out what happened:
exports.postRegister = function(req, res){
login = mongoose.model('login');
login.register(new login ({ username : req.body.email}),req.body.password, function(err, login){
if (err){
return res.render('register', { login: login, error: err, title: "S'enregistrer" });
}
passport.authenticate('local', function(err, user){
console.log(arguments);
})(req, res, function(){
res.redirect('/scene/1');
});
});
};
And the .log (arguments) console returns:
{ '0': null,
'1': false,
'2': { message: 'Missing credentials' },
'3': 400 }
I have a check on my MongoDB, the user is created without problems!
source
share