I need to validate non empty fields before post login, but I get this error:
TypeError: req.checkBody is not a function
at D:\IDoo projects\ExpressGenerado\config\routes.js:76:9
This is my route file:
app.post('/login',function(req,res){
req.checkBody('email', 'Email is required').notEmpty();
req.checkBody('password', 'Password is required').notEmpty();
var errors = req.validationErrors();
if (errors) {
res.render('signup',{message: req.flash('loginMessage')});
}
else{
passport.authenticate('local-login', {
successRedirect : '/profile', // redirect to the secure profile section
failureRedirect : '/login', // redirect back to the signup page if there is an error
failureFlash : true // allow flash messages
})(req,res);
}
});
via Yanet Pedraza
No comments:
Post a Comment