1

我正在关注scotch.io提供的 passport.js 身份验证教程,它实际上在我的浏览器上运行,但由于我正在开发 REST API,我正在放慢更改代码的某些部分,例如不需要 ejs模块。我正在尝试使用 chrome 的 Postman 和 Basic Auth 为用户注册发布请求,但到目前为止无济于事,身份验证总是失败并重新重定向到注册。以下是报名帖:

app.post('/signup', passport.authenticate('local-signup', {
        successRedirect : '/login', // redirect to the secure profile section
        failureRedirect : '/signup', // redirect back to the signup page if there is an error
        failureFlash : true // allow flash messages
    }));

有人可以向我解释为什么不能使用不是通过 signup.ejs 模板发出的发布请求,以及如何将 scotch 实现更改为 REST 之类的东西?

4

1 回答 1

0

您是否更改了<input>新模板中的名称?这很可能是原因。Passport 查找两个输入字段名称:usernamepassword。如果这些不存在,则不会找到任何凭据。

于 2014-11-07T17:46:39.890 回答