// User requests the /app/ route -> Check if he is authenticated | |
router.get('/app/', isAuthenticated, (req, res) => res.render('app') ); | |
// The isAuthenticated function is using passport.js here to see if the user is logged in (req.isAuthenticated) | |
// It that's not the case, we redirect them to the login route. | |
const isAuthenticated = (req, res, next) => { | |
if(req.isAuthenticated()) return next(); | |
res.redirect('/login'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment