Hey guys im trying to make my admin page off limits to all the users except the one i have named john. What i have in my app.js file is
app.get('/admin',requireLogin, function(req, res){
res.render('admin', {
title: 'Admin'});
});
function requireLogin (req, res, next) {
if (req.user.username ==='john') {
next();
} else {
res.redirect('/login');
}
};
Aucun commentaire:
Enregistrer un commentaire