【发布时间】:2012-05-09 19:49:22
【问题描述】:
我正在使用 Passport-Local (https://github.com/jaredhanson/passport-local) 对 node.js 进行身份验证。到目前为止,这个例子就像一个魅力,因为用户正在通过 post-webform 登录:
app.post('/login',
passport.authenticate('local', { failureRedirect: '/login', failureFlash: true }),
function(req, res) {
res.redirect('/');
});
不过,现在我想编写一个基于 JSON 的 API,通过调用特定 URL 来验证用户身份。将代码块修改为app.get(… 不起作用。
有什么建议吗?
【问题讨论】:
-
更新:似乎护照使用
req.body作为用户名/密码。如果我破解本地护照以使用req.query它可以工作。虽然不是我喜欢的方法……
标签: node.js middleware