Last active
February 25, 2016 19:40
-
-
Save Qaaj/2ef39c23673c15aedb3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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