Instantly share code, notes, and snippets.

Embed
What would you like to do?
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')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment