node.js - 如何在 node-oidc-provider 中重定向失败的登录尝试
问题描述
我正在使用 node.js、express.js 和 node-oidc-provider 设置 OpenID Connect 提供程序。我一直在研究https://github.com/panva/node-oidc-provider-example/tree/master/03-oidc-views-accounts上的示例,但它从不处理失败的身份验证。如果用户输错密码,如何将用户重定向回登录页面?
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);
});
解决方案
就像在任何快递应用程序中一样。这样想吧。如果您希望退出交互并将控制权返回给客户端,请仅以成功或错误解决交互。
我倾向于单独开发交互,只有在完成后才将它们插入 oidc-provider。
推荐阅读
- python - Python pyglet 不停地重复播放音频
- php - 限制循环的数量,然后将其传递给下一个进程
- c# - c#指纹生物识别,UserConsentVerificationResult()无响应(WPF)
- dvc - 没有导入的派生数据的 DVC 依赖项
- python - 如何使用 Python 将 RGB565 字节数组转换为 RGB888 字节数组?
- c# - 如何首先打开一个窗口,而不是 WPF 中的 MainWindow(C#)
- javascript - 如何在javascript中的字符串内创建嵌套for循环
- metabase - 对远程服务器进行 REST API 调用 - 元数据库
- asp.net - ASP.NET 文件上传不会在更新面板中保留回发文件
- flutter - Flutter AnimatedList 与提供者模式