Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save christopher4lis/f7121a07740e5dbca860c9beb2910565 to your computer and use it in GitHub Desktop.
Save christopher4lis/f7121a07740e5dbca860c9beb2910565 to your computer and use it in GitHub Desktop.
Used to restrict access to particular pages in combination with Passport.js
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')
}
}
@rlavigne99
Copy link

I would just like to say that I think your course was great. I am learning so much :) Thanks and keep it up!

@bustinjurkz
Copy link

Thank you so much for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment