aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/dashboard/dashboard.html20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html
index dd37f29..a20e64c 100644
--- a/src/api/dashboard/dashboard.html
+++ b/src/api/dashboard/dashboard.html
@@ -2719,7 +2719,7 @@ async function logOut() {
"The page is let in still, by other means."));
obtainTokens();
} catch (_) {
- location.assign("../login");
+ toLogin();
}
}
// The user's credentials: its keys (`/auth/keys`): each edited (its name, its line),
@@ -2904,7 +2904,7 @@ async function obtainTokens() {
showWho();
// The login ended (or none): to the login page; else (the node away) again soon.
if ([400, 401, 403].includes(error.status)) {
- location.assign("../login");
+ toLogin();
return;
}
tokenTimer = setTimeout(obtainTokens, 30000);
@@ -4374,6 +4374,22 @@ remakeForm.addEventListener("submit", event => {
.catch(error => remakeResult("Proposing failed: " + error, true));
});
+// To the login page, the page's reading stopped first: its stream, its subscriptions,
+// its timers and tokens. A page the browser brings back from its history as it was
+// (back, forward: `pageshow` of a page kept whole) is loaded again instead, so it shows
+// nothing its session no longer lets it read, and goes to the login page without one.
+function toLogin() {
+ clearTimeout(retry);
+ retry = null;
+ if (events) events.close();
+ for (const entry of subscribed.values()) entry.stop();
+ subscribed.clear();
+ clearTimeout(tokenTimer);
+ clearTimeout(figuresTimer);
+ token = narrowToken = null;
+ location.assign("../login");
+}
+addEventListener("pageshow", event => { if (event.persisted) location.reload(); });
// Opened from another member's page (`handOver`) with a token: it begins this browser's
// session here before anything is read, with no login page in between. Without a
// session, `obtainTokens` goes to the login page.