繁体   English   中英

如何在身份服务器身份验证 oidc-client Angular 后关闭 signinPopup() 窗口

[英]How To Close signinPopup() Window After Identity Server Authentication oidc-client Angular

我有一个 Angular 应用程序,我需要通过 Identity Server 4 对用户进行身份验证。我在 UserManager 上使用 signinPopup() 方法。 这按设计工作。 当我启动登录时,它会打开弹出窗口和登录表单。

登录成功,但不是关闭弹出窗口和登录声明信息被传递到“打开器”窗口,它只是在弹出窗口中加载 post_login_redirect_uri。

我需要它来关闭此窗口,然后该数据可用于启动 signinPopup 的应用程序,而不是在弹出窗口本身中。

而且,如果我手动关闭该窗口,数据仍然不会传递回主(弹出窗口的发起者)窗口。 改为捕获错误。

我一直在研究并发现了一些关于如何做到这一点的帖子,但没有描述性。 我不认为编辑身份服务器登录代码来处理关闭弹出窗口是执行此操作的“正确”方法。

有人可以帮忙吗?

//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)
})

}

我有同样的问题,并在 oidc-client 的 github 上的示例代码中找到了线索

在此示例中, signinPopup() 重定向到一个页面,该页面仅调用new Oidc.UserManager().signinPopupCallback();

这将关闭弹出窗口并成功解析来自父页面的承诺。

它可能就像使用 popup_redirect_uri 而不是 post_login_redirect_uri 一样简单。 https://github.com/IdentityModel/oidc-client-js/wiki

暂无
暂无

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

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