diff --git a/public/app/core/services/backend_srv.ts b/public/app/core/services/backend_srv.ts index 64ac099efba..72be4f2ff4d 100644 --- a/public/app/core/services/backend_srv.ts +++ b/public/app/core/services/backend_srv.ts @@ -382,6 +382,7 @@ export class BackendSrv implements BackendService { }, }) ); + this.dependencies.contextSrv.setRedirectToUrl(); return throwError(() => error); } diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts index 54e5c27594b..8d14b656fa2 100644 --- a/public/app/core/services/context_srv.ts +++ b/public/app/core/services/context_srv.ts @@ -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) {