Last active
July 13, 2018 19:21
-
-
Save thihenos/91b8b4e4e234e203feba753772122179 to your computer and use it in GitHub Desktop.
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.IsAuthenticated = function(req,res,next){ | |
//Passport creates a function to your session called isAuthenticated(), so you can use it to verify if the user really login in the app | |
console.log(req.isAuthenticated()); | |
if(req.isAuthenticated()){ | |
//So, here you are saying that if the route called had any other function, it will goes to the next one ( which is rendering the HTML ) | |
next(); | |
}else{ | |
//Or else, goes back to login page | |
res.render('welcome/index',{message:'Ops! This route requires a login!'}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment