Auth: Fix redirection in case of ERR_TOKEN_REVOKED (#94137)

Fix redirection in case of token revoked error
This commit is contained in:
Misi
2024-10-02 12:08:25 +02:00
committed by GitHub
parent 573ba9be18
commit ddbbf8df4b
2 changed files with 9 additions and 4 deletions
+1
View File
@@ -382,6 +382,7 @@ export class BackendSrv implements BackendService {
}, },
}) })
); );
this.dependencies.contextSrv.setRedirectToUrl();
return throwError(() => error); return throwError(() => error);
} }
+8 -4
View File
@@ -120,16 +120,20 @@ export class ContextSrv {
* Indicate the user has been logged out * Indicate the user has been logged out
*/ */
setLoggedOut() { setLoggedOut() {
this.setRedirectToUrl();
this.cancelTokenRotationJob();
this.user.isSignedIn = false;
this.isSignedIn = false;
window.location.reload();
}
setRedirectToUrl() {
if (config.featureToggles.useSessionStorageForRedirection) { if (config.featureToggles.useSessionStorageForRedirection) {
window.sessionStorage.setItem( window.sessionStorage.setItem(
RedirectToUrlKey, RedirectToUrlKey,
encodeURIComponent(window.location.href.substring(window.location.origin.length)) encodeURIComponent(window.location.href.substring(window.location.origin.length))
); );
} }
this.cancelTokenRotationJob();
this.user.isSignedIn = false;
this.isSignedIn = false;
window.location.reload();
} }
hasRole(role: string) { hasRole(role: string) {