什么是req.isAuthenticated()passportJS
在PassportJS Documention中,我认为护照authenticationfunction没有很好的logging。
我想问,什么passport.isAuthenticated()ID做?
对于任何请求,您可以检查用户是否通过身份validation或使用此方法。
app.get('/some_path',checkAuthentication,function(req,res){ //do something only if user is authenticated }); function checkAuthentication(req,res,next){ if(req.isAuthenticated()){ //if user is looged in, req.isAuthenticated() will return true next(); } else{ res.redirect("/login"); } }