[英]How passport.authenticate() determine successRdirect or failureRedirect?
I beginner to nodejs and trying to apply authentication using (passport,passport-local) and using local strategy.in local strategy i check email and password and compare it with database record.if email and password is correct I return done(null, user) call back.Then in passport.authenticate() how it determines to redirect to failureRedirect or successRedirect?我是nodejs的初学者并尝试使用(passport,passport-local)和使用本地策略应用身份验证。在本地策略中我检查email和密码并将其与数据库记录进行比较。如果email和密码正确我返回完成(空,用户)回调。然后在passport.authenticate()中它如何确定重定向到failureRedirect或successRedirect?
router.post('/login', passport.authenticate('local',
{
successRedirect: '/',
failureRedirect: '/login'
}
));
While Authenticating with passport
.在使用
passport
进行身份验证时。 Strategies require what is known as a verify callback .策略需要所谓的验证回调。 The purpose of a verify callback is to find the user that possesses a set of credentials.
验证回调的目的是找到拥有一组凭据的用户。
You can return 3 types of callback result可以返回 3 种类型的回调结果
done(err)
which just returns if error occurs while processing. done(err)
仅在处理时发生错误时返回。
done(null, false, {custom Message})
which means no error
but either email
or password
didn't matched. done(null, false, {custom Message})
表示没有error
,但email
或password
不匹配。
done(null, user)
which means no error
and successful authentication done(null, user)
这意味着没有error
和成功的身份验证
based on what is returned failureRedirect or successRedirect is decided根据返回的内容来决定 failureRedirect 或 successRedirect
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.