I\'m utilizing Passport to create a Google OAuth2 authentication system. I\'m trying to write the route files in Coffeescript for it, except for some reason I keep getting t
You haven't set isLoggedIn
before using it, so it is still undefined at that point.
Move this:
isLoggedIn = function(req, res, next) {
if (req.isAuthenticated()) {
return next();
}
return res.redirect('/');
};
before this line:
router.get('/editor', isLoggedIn, function(req, res) {
Or get rid of the isLoggedIn
variable and use function isLoggedIn() {}
syntax to have the function hoisted:
function isLoggedIn(req, res, next) {
if (req.isAuthenticated()) {
return next();
}
return res.redirect('/');
};