簡體   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