简体   繁体   English

如何在node-oidc-provider中重定向失败的登录尝试

[英]How do I redirect a failed login attempt in node-oidc-provider

I'm setting up an OpenID Connect Provider using node.js, express.js, and node-oidc-provider. 我正在使用node.js,express.js和node-oidc-provider设置OpenID Connect提供程序。 I've been working my way through the examples at https://github.com/panva/node-oidc-provider-example/tree/master/03-oidc-views-accounts , but it never deals with a failed authentication. 我一直在通过https://github.com/panva/node-oidc-provider-example/tree/master/03-oidc-views-accounts上的示例进行操作,但是它永远不会处理失败的身份验证。 How do I redirect the user back to the login page if they mis-type their password? 如果用户输入了错误的密码,如何将用户重定向回登录页面?

expressApp.get('/interaction/:grant', async (req, res) => {
// The initial route hit by the client (Relying Party) that renders the login view if needed.
...
});

expressApp.post('/interaction/:grant/login', parse, (req, res, next) => {
        User.authenticate(req.body.email, req.body.password)
            .then((users) => {
             // returns an array of user objects that match the credentials
              if(!users.length)
              {
              // What now?  I can't just redirect back to /interaction/:grant - I get session not found

              }
      // the rest works well enough (for now)....
...
            }).catch(next);
      });

Just like in any express app. 就像在任何快速应用中一样。 Think of it this way. 这样想吧。 Only resolve the interactions with success, or error if you wish to exit the interactions and return control back to the client. 仅成功解决交互问题,否则,如果您希望退出交互并将控制权交还给客户端,则会出错。

I tend to develop interactions separately and only plug them to oidc-provider when they're done. 我倾向于单独开发交互,只有在完成后才将它们插入oidc-provider。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM