In passportJS Documentation, I think passport isAuthenticated
function not documented well.
How is req.isAuthenticated()
in PassportJS implemented?
For any request you can check if a user is authenticated or not using this method.
app.get('/some_path',checkAuthentication,function(req,res){ //do something only if user is authenticated }); function checkAuthentication(req,res,next){ if(req.isAuthenticated()){ //req.isAuthenticated() will return true if user is logged in next(); } else{ res.redirect("/login"); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With