Kim*_*Kim 49 node.js passport.js
在passportJS文件中,我认为护照认证功能没有记录好.
我想问一下,passport.isAuthenticated()id是做什么的?
Anu*_*thi 70
对于任何请求,您可以使用此方法检查用户是否已通过身份验证.
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");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40773 次 |
| 最近记录: |