Reputation: 174
I am using the @azure/msal-angular version 2 and Angular version 13. The scenario is when the user signed in to the application need to authorize the user if he doesn't have access need to sign out the user from the application. which will be happened in background by calling msalService.logoutRedirect(). While calling the logout function the microsoft account selection screen is displayed to signout instead of auto signout. Is there any way to skip the account selection screen to siignout.
Upvotes: 7
Views: 8563
Reputation: 4299
As mentioned here in the documentation: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#skipping-the-server-sign-out You may logout from your application without affecting their login status in other applications
msalInstance.logoutRedirect({
onRedirectNavigate: (url) => {
// Return false if you would like to stop navigation after local logout
return false;
}
});
Upvotes: 1
Reputation: 12361
To do this, first you have to setup the login_hint
optional claim in the ID token. That needs to be done on the app registration side of things. (Azure Portal -> App Registration -> Token Configuration -> Add Optional Claim -> ID -> login_hint)
Once that claim is in place, MSAL will pass that into logoutRedirect()
and will skip the account picker prompt.
const account = this.msalService.instance.getActiveAccount();
this.msalService.logoutRedirect({ account: account });
Upvotes: 11