use new code of login post -------------------------------------- app.post("/login",function(req, res){ const username = req.body.username; const password = req.body.password; User.findOne({email:username}) .then(function(foundUser) { if(foundUser){ if(foundUser.password === password){ res.render("secrets"); } } }) .catch(function(err) { console.log(err); }); }); *************************************************************************************** instead of old code of login post ---------------------------------------------------------------- app.post("/login", function(req, res){ const username = req.body.username; const password = req.body.password; User.findOne({email: username}, function(err, foundUser){ if (err) { console.log(err); } else { if (foundUser){ if (foundUser.password === password){ res.render("secrets"); } } } }); });