Hi guys,
Question I have, is it possible to logout from one tab and make sure all the other tabs that are open are logged out too, is there an API for this?
I’m using Angular application and the latest Okta angular SDK.
Thanks.
Hi guys,
Question I have, is it possible to logout from one tab and make sure all the other tabs that are open are logged out too, is there an API for this?
I’m using Angular application and the latest Okta angular SDK.
Thanks.
What’s the current behavior you are seeing? The Angular SDK uses the logout API which clears the user’s session.
See: GitHub - okta/okta-angular: Angular SDK for Okta's OIDC flow
logout() {
this.oktaAuth.signOut();
}
Hi, what I am seeing is the tab I trigger the signout in goes to the okta login page, while the other stays on the page.
And you are using the method I linked to above? That should both end the session as well as revoke tokens. Have you tried to reproduce in the samples app? I’ve tested this on my end using the sample and when I logout at one tab, all others are logged out and redirected to the login page as well.
yes I am, signOut().
on my local it is very inconsistent for example:
If I’ve got two tabs open and don’t go the other tabs. Only the tab I am on logouts.
But on our live environment it never works.
Do you mind sharing the code for where you are calling signOut()?
sure! FYI we’re using NGRX.
public logout$ = createEffect(
() =>
this.actions$.pipe(
ofType(logout),
tap(async () => {
await this.oktaAuth.signOut({ postLogoutRedirectUri: environment.okta.postLogoutRedirectUri });
this.cookies.deleteAll(’/’);
localStorage.clear();
})
),
{ dispatch: false }
);
Only solution I’ve got at the moment is using tokenManager.on
removed, GitHub - okta/okta-auth-js: The official js wrapper around Okta's auth API.
This event seems to get detected in the other tab. So have to use something like this:
public tokenRemoved$ = createEffect(
() =>
this.tokenRemoved.pipe(
map(() => {
this.oktaAuth.signOut({ postLogoutRedirectUri: environment.okta.postLogoutRedirectUri });
})
),
{ dispatch: false }
);
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.