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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -382,6 +382,7 @@ export class BackendSrv implements BackendService {
},
})
);
this.dependencies.contextSrv.setRedirectToUrl();
return throwError(() => error);
}

View File

@ -120,16 +120,20 @@ export class ContextSrv {
* Indicate the user has been logged out
*/
setLoggedOut() {
this.setRedirectToUrl();
this.cancelTokenRotationJob();
this.user.isSignedIn = false;
this.isSignedIn = false;
window.location.reload();
}
setRedirectToUrl() {
if (config.featureToggles.useSessionStorageForRedirection) {
window.sessionStorage.setItem(
RedirectToUrlKey,
encodeURIComponent(window.location.href.substring(window.location.origin.length))
);
}
this.cancelTokenRotationJob();
this.user.isSignedIn = false;
this.isSignedIn = false;
window.location.reload();
}
hasRole(role: string) {