Skip to content

Commit 01a0720

Browse files
author
Erwin Dondorp
committed
fixed logout warning, closes #413
1 parent 6a62274 commit 01a0720

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

saltgui/static/scripts/pages/Logout.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ export class LogoutPage extends Page {
1717
}, 60000);
1818

1919
// verify often for an expired session that we expect
20-
this.sessionTimeoutInterval = window.setInterval(() => {
21-
if (Utils.getStorageItem("session", "token", null) === null) {
22-
window.clearInterval(this.sessionTimeoutInterval);
23-
return;
24-
}
20+
window.setInterval(() => {
2521
this._updateSessionTimeoutWarning();
2622
}, 1000);
2723
}
@@ -57,6 +53,13 @@ export class LogoutPage extends Page {
5753
_updateSessionTimeoutWarning () {
5854
const warning = document.getElementById("warning");
5955

56+
if (Utils.getStorageItem("session", "token", null) === null) {
57+
// cannot force logout without session
58+
warning.style.display = "";
59+
warning.innerText = "No session";
60+
return;
61+
}
62+
6063
const loginResponseStr = Utils.getStorageItem("session", "login-response", "{}");
6164
const loginResponse = JSON.parse(loginResponseStr);
6265

saltgui/static/scripts/panels/Options.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ export class OptionsPanel extends Panel {
168168
durationStr = "\nduration is " + str1.substr(11, 8);
169169
}
170170
let expiresInStr = "";
171-
const str2 = new Date(pSessionExpire * 1000 - Date.now()).toISOString();
172-
if (str2.startsWith("1970-01-01T")) {
171+
const leftMillis = pSessionExpire * 1000 - Date.now();
172+
if (leftMillis < 0) {
173+
expiresInStr = "\nexpired";
174+
} else if (leftMillis < 86400000) {
175+
const str2 = new Date(leftMillis).toISOString();
173176
// remove the date prefix and the millisecond suffix
174177
expiresInStr = "\nexpires in " + str2.substr(11, 8);
175178
}

0 commit comments

Comments
 (0)