Commit e2ecb700 by Oscar Kilhed Committed by GitHub

Dashboard: Ignore changes to dashboard when the user session expires (#30897)

When the user session expires, and the 401 triggers a page reload to get the user to the login page, ChangeTracker will interfer. By setting the user as logged out in the context when the session is timed out, we can ignore the changes in ChangeTracker.
parent 0ddf1c8e
...@@ -39,6 +39,7 @@ export class BackendSrv implements BackendService { ...@@ -39,6 +39,7 @@ export class BackendSrv implements BackendService {
appEvents: appEvents, appEvents: appEvents,
contextSrv: contextSrv, contextSrv: contextSrv,
logout: () => { logout: () => {
contextSrv.setLoggedOut();
window.location.reload(); window.location.reload();
}, },
}; };
......
...@@ -49,6 +49,14 @@ export class ContextSrv { ...@@ -49,6 +49,14 @@ export class ContextSrv {
this.minRefreshInterval = config.minRefreshInterval; this.minRefreshInterval = config.minRefreshInterval;
} }
/**
* Indicate the user has been logged out
*/
setLoggedOut() {
this.user.isSignedIn = false;
this.isSignedIn = false;
}
hasRole(role: string) { hasRole(role: string) {
return this.user.orgRole === role; return this.user.orgRole === role;
} }
......
...@@ -93,6 +93,11 @@ export class ChangeTracker { ...@@ -93,6 +93,11 @@ export class ChangeTracker {
return true; return true;
} }
//Ignore changes if the user has been signed out
if (!this.contextSrv.isSignedIn) {
return true;
}
const meta = this.current.meta; const meta = this.current.meta;
return !meta.canSave || meta.fromScript || meta.fromFile; return !meta.canSave || meta.fromScript || meta.fromFile;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment