【发布时间】:2014-12-13 22:02:24
【问题描述】:
我正在尝试设置一个 LocalStrategy,可以在没有在请求正文中提供凭据的情况下登录
app.post('/signin', passport.authenticate('local-signin', {failureFlash : true}), function (req, res) {
res.send(req.user);
});
策略如下:
passport
.use('local-signin', new LocalStrategy({
usernameField : 'email',
passwordField : 'password',
passReqToCallback : true
},
function (req, email, password, done) {
if (email.length > 0 && password.legnth > 0) {
/** Do some stuff with credentials **/
}
else {
console.log('method2');
/** Other method to log in with request headers...**/
}
});
不幸的是,当我在没有正文的情况下向/signin 发布请求时,出现状态 400 错误,并且未加载策略(在示例中,我没有在控制台中写入 method2)。
有没有办法将 Passport 配置为接受没有正文的请求?
有关信息,我使用 AngularJS 前端,请求使用 $http.post('/signin');
护照版本:0.2.1
护照本地版本:1.0.0
【问题讨论】:
标签: node.js passport.js