here is my router:
router.post('/login',
passport.authenticate('local'),
(req, res, next) => {
body('backurl').trim().escape();
let referrer = req.get('Referrer')
if (!req.user) {
return res.render('login', {
message: 'Unable to login, the password or the username are wrong',
backUrl: referrer
});
}
if (req.body.backurl == null || req.body.backurl == 'http://localhost:3000/signup' || req.body.backurl == 'http://localhost:3000/login') {
return res.redirect('/yourcourses');
}
return res.redirect(req.body.backurl);
}
);
When the user and the local authentication works it does work perfectly, however on fail I want to render the login page again with a message and a variable, however on failure the website simply makes an empty page with the word "unauthorized" on it without anything else, how do I fix it? thanks!
CodePudding user response: