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.
pull/30910/head
Oscar Kilhed 4 years ago committed by GitHub
parent 0ddf1c8ee0
commit e2ecb70051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      public/app/core/services/backend_srv.ts
  2. 8
      public/app/core/services/context_srv.ts
  3. 5
      public/app/features/dashboard/services/ChangeTracker.ts

@ -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;
}

Loading…
Cancel
Save