更新时间:2022-01-03 07:54:01
这应该工作,未经考验的,让我知道,如果有错别字。
This should work, untested, let me know if there's typos.
基本上,你需要你的前任preSS应用程序来侦听/登录POST请求,在这条路线,你可以添加你的护照身份验证。
Basically, you need your express app to listen for a POST request on /login, in this route, you can add your passport auth.
app.post('/login', function(req, res, next) {
passport.authenticate('loginUsers', function(err, user, info) {
if (err) { return next(err); }
if (!user) { return res.render('account'); }
req.logIn(user, function(err) {
if (err) { return next(err); }
return res.json({detail: info});
});
})(req, res, next);
});
此外,在你的战略,确保字段名称是正确的,即:
Also, in your strategy, make sure the fields name are correct ie:
passport.use('loginUsers',new LocalStrategy({
usernameField : 'username',
passwordField : 'password',
passReqToCallback : true
},