Created
June 22, 2017 23:07
-
-
Save christopher4lis/f7121a07740e5dbca860c9beb2910565 to your computer and use it in GitHub Desktop.
Used to restrict access to particular pages in combination with Passport.js
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
function authenticationMiddleware () { | |
return (req, res, next) => { | |
console.log(`req.session.passport.user: ${JSON.stringify(req.session.passport)}`); | |
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
I would just like to say that I think your course was great. I am learning so much :) Thanks and keep it up!