【问题标题】:Passport.js Local Strategy Auth ConfigPassport.js 本地策略认证配置
【发布时间】:2015-01-01 03:53:20
【问题描述】:

我正在关注 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 之类的东西?

【问题讨论】:

    标签: node.js rest passport-local passport.js


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 2018-11-10
      • 2017-09-18
      • 1970-01-01
      • 2016-10-12
      • 2014-03-20
      • 2014-11-12
      • 2013-08-29
      • 1970-01-01
      相关资源
      最近更新 更多