Skip to content

Commit

Permalink
fix: login form not shown when session expires #350
Browse files Browse the repository at this point in the history
(cherry picked from commit 8e371096abb66bead60799efd2192cc1feb070cf)
  • Loading branch information
vyacheslav-pushkin committed Dec 29, 2020
1 parent 52a3baa commit 63854d9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/jmix-react-core/src/app/MainStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export class MainStore {
private messagesRequestCount = 0;
private enumsRequestCount = 0;

private disposeTokenExpiryListener?: () => {};

constructor(private cubaREST: CubaApp) {
this.cubaREST.onLocaleChange(this.handleLocaleChange);
this.security = new Security(this.cubaREST);
Expand Down Expand Up @@ -130,6 +132,9 @@ export class MainStore {
return this.cubaREST.login(login, password).then(action(() => {
this.userName = login;
this.authenticated = true;
this.disposeTokenExpiryListener = this.cubaREST.onTokenExpiry(() => {
this.authenticated = false;
});
}))
}

Expand All @@ -143,6 +148,10 @@ export class MainStore {
return this.cubaREST.logout()
.then(action(() => {
this.authenticated = false;
if (this.disposeTokenExpiryListener != null) {
this.disposeTokenExpiryListener();
this.disposeTokenExpiryListener = undefined;
}
}));
}
return Promise.resolve();
Expand Down

0 comments on commit 63854d9

Please sign in to comment.