Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is req.isAuthenticated() in Passport JS implemented? [closed]

In passportJS Documentation, I think passport isAuthenticated function not documented well.

How is req.isAuthenticated() in PassportJS implemented?

like image 495
Kim Avatar asked Aug 08 '16 01:08

Kim


1 Answers

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");     } } 
like image 178
Anurag Awasthi Avatar answered Sep 20 '22 18:09

Anurag Awasthi