feat: connect settings live flow to auth api

This commit is contained in:
a.tolmachev
2026-03-31 02:21:31 +03:00
parent 61718bce5a
commit 44363c0b1c
13 changed files with 502 additions and 102 deletions
+9 -5
View File
@@ -56,6 +56,12 @@
} catch (_error) {}
}
function replaceSession(session) {
sessionCache = session;
persistUserMirror(session);
return session;
}
async function fetchSession(force) {
if (!force && sessionCache) {
return sessionCache;
@@ -66,9 +72,7 @@
sessionPromise = window.CrankApi.getSession()
.then(function(session) {
sessionCache = session;
persistUserMirror(session);
return session;
return replaceSession(session);
})
.catch(function(error) {
clearUserMirror();
@@ -109,8 +113,7 @@
email: email,
password: password,
});
sessionCache = session;
persistUserMirror(session);
replaceSession(session);
window.location.href = homeUrl();
}
@@ -134,6 +137,7 @@
window.CrankAuth = {
fetchSession: fetchSession,
replaceSession: replaceSession,
guardProtectedPage: guardProtectedPage,
guardLoginPage: guardLoginPage,
login: login,