feat: complete Epic 1 production foundation
This commit is contained in:
@@ -175,6 +175,15 @@
|
||||
}
|
||||
|
||||
sessionPromise = window.CrankApi.getSession()
|
||||
.then(function(session) {
|
||||
if (session && !session.csrf_token && window.CrankApi && typeof window.CrankApi.refreshSessionCsrf === 'function') {
|
||||
return window.CrankApi.refreshSessionCsrf().then(function(csrf) {
|
||||
session.csrf_token = csrf && csrf.csrf_token ? csrf.csrf_token : '';
|
||||
return session;
|
||||
});
|
||||
}
|
||||
return session;
|
||||
})
|
||||
.then(function(session) {
|
||||
return replaceSession(session);
|
||||
})
|
||||
@@ -221,6 +230,15 @@
|
||||
window.location.href = homeUrl();
|
||||
}
|
||||
|
||||
async function completeBootstrap(token, password) {
|
||||
var session = await window.CrankApi.completeBootstrap({
|
||||
token: token,
|
||||
password: password,
|
||||
});
|
||||
replaceSession(session);
|
||||
window.location.href = homeUrl();
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
try {
|
||||
await window.CrankApi.logout();
|
||||
@@ -243,12 +261,16 @@
|
||||
fetchSession: fetchSession,
|
||||
replaceSession: replaceSession,
|
||||
getCachedSession: function() { return sessionCache; },
|
||||
getCsrfToken: function() {
|
||||
return sessionCache && sessionCache.csrf_token ? sessionCache.csrf_token : '';
|
||||
},
|
||||
renderShellIdentity: function() {
|
||||
renderShellIdentity(sessionCache);
|
||||
},
|
||||
guardProtectedPage: guardProtectedPage,
|
||||
guardLoginPage: guardLoginPage,
|
||||
login: login,
|
||||
completeBootstrap: completeBootstrap,
|
||||
logout: logout,
|
||||
handleUnauthorized: handleUnauthorized,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user