我有一个Angular应用程序,我需要它通过Identity Server4对用户进行身份验证。我在UserManager上使用signinPopup()方法。这就像设计的那样工作。当我启动登录时,它会打开弹出窗口和登录表单。
登录是成功的,但不是关闭popUp窗口,而是将登录声明信息传递到"opener“窗口,它只是在弹出窗口中加载post_login_redirect_uri。
我需要它来关闭此窗口,然后数据可用于启动signinPopup的应用程序,而不是弹出窗口本身。
而且,如果我手动关闭该窗口,数据仍然不会传回主(弹出窗口的发起者)窗口。而是捕获错误。
我一直在研究,找到了几篇关于如何做到这一点的帖子,但没有描述性的内容。我不认为通过编辑Identity Server登录代码来处理关闭弹出窗口是“正确”的方法。
有人能帮上忙吗?
//THis launches popup and authentication is successful.
startSigninPopup(){
this.mgr.signinPopup().then((user) =>{
console.log(user);
return user;
}).catch((error) => {
// if manually closing the popup, I end up in catch with error.
console.log(error)
})}
发布于 2019-11-21 06:40:29
我也有同样的问题,并在oidc-client的github上的示例代码中找到了线索
在此示例中,signinPopup()重定向到一个仅调用new Oidc.UserManager().signinPopupCallback();的页面
这将关闭弹出窗口,并成功解析来自父页面的promise。
发布于 2019-05-04 02:20:44
它可能和使用popup_redirect_uri而不是post_login_redirect_uri一样简单。请参阅https://github.com/IdentityModel/oidc-client-js/wiki
https://stackoverflow.com/questions/55974904
复制相似问题