Created
February 29, 2012 14:48
-
-
Save BenHall/1941301 to your computer and use it in GitHub Desktop.
passport.js auth route
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
exports.ensureAuthenicated = function(req, res, next) { | |
if (req.isAuthenticated()) { return next(); } | |
res.redirect('/login') | |
} |
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
var passport = require('./auth/passport'); | |
app.get('/', passport.ensureAuthenicated, function(req, res){ | |
res.redirect('/acquisition'); | |
}); |
Yep, any routes which require the user to be logged in need to have that in the pipeline.
thanks ! worked like a champ.
Just a small typo:
ensureAuthenicated
which should be
ensureAuthenticated
Had me thrown off for a bit :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, cool. So I have to stuff that ensureAuthenticated in each time? Thanks Ben!