MSAL v2 Angular - 注销问题

问题描述 投票:0回答:1

我正在使用 @azure/msal-Angular 版本 2 和 Angular 版本 13。场景是在调用注销功能时,Microsoft 帐户成功注销应用程序 ( APP A )。但理想情况下,除了这个应用程序(应用程序 A)之外,已经登录的其他应用程序(使用 Microsoft)不应注销。

(Microsoft Teams、Outlook 等应用程序...)这些应用程序是我在同一浏览器中打开的。

下面的注销代码。

let accountId  = this.authService.instance.getAllAccounts()[0]?.homeAccountId;

const accountInfoActiveAcc = this.authService.instance.getAccountByHomeId(accountId);

this.authService.logoutPopup({ account: accountInfoActiveAcc });

请帮我解决这个问题。预先感谢。

angular azure-ad-msal msal-angular msal
1个回答
1
投票

在您描述的场景中,您希望注销当前应用程序而不注销其他应用程序。为此,您应该将

mainWindowRedirectUri
参数设置为应用程序的重定向 URI。这将确保您的应用程序保持登录状态,即使用户已从其 Microsoft 帐户注销。

以下是如何注销当前应用程序而不注销其他应用程序的示例:

在我的 component.ts 中更新注销如下

logout() {
if (this.msalGuardConfig.interactionType  ===  InteractionType.Popup) {
this.authService.logoutPopup({
mainWindowRedirectUri:  "/"
});
} else {
this.authService.logoutRedirect({
mainWindowRedirectUri:  "/",
});
} 
}

结果 我在本地主机中使用凭据打开了我的应用程序 enter image description here

enter image description here

enter image description here

enter image description here

注销后我可以保持登录其他应用程序

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.