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 {
appEvents: appEvents,
contextSrv: contextSrv,
logout: () => {
contextSrv.setLoggedOut();
window.location.reload();
},
};
......
......@@ -49,6 +49,14 @@ export class ContextSrv {
this.minRefreshInterval = config.minRefreshInterval;
}
/**
* Indicate the user has been logged out
*/
setLoggedOut() {
this.user.isSignedIn = false;
this.isSignedIn = false;
}
hasRole(role: string) {
return this.user.orgRole === role;
}
......
......@@ -93,6 +93,11 @@ export class ChangeTracker {
return true;
}
//Ignore changes if the user has been signed out
if (!this.contextSrv.isSignedIn) {
return true;
}
const meta = this.current.meta;
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