我正在使用node.js、express.js和OpenID -oidc- Provider设置节点连接提供程序。我一直在研究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);
});发布于 2019-02-16 06:47:26
就像在任何express应用程序中一样。这样想吧。如果您希望退出交互并将控制权交还给客户端,则仅解决成功或错误的交互。
我倾向于单独开发交互,只有在完成时才将它们插入oidc-provider。
https://stackoverflow.com/questions/54699216
复制相似问题