fix: account state

This commit is contained in:
Torsten Dittmann
2022-10-14 17:17:35 +02:00
parent d90e13396c
commit 49c17d70eb
4 changed files with 14 additions and 5 deletions
+4
View File
@@ -13,6 +13,10 @@ function createUserStore() {
},
logout: async () => {
await sdkForConsole.account.deleteSession('current');
/**
* Clear cache.
*/
globalThis.sessionStorage.clear();
}
};
}
+9 -1
View File
@@ -24,6 +24,8 @@
try {
if (!$user) {
await user.fetchUser();
} else {
user.fetchUser();
}
if (!$page.url.pathname.startsWith('/console')) {
@@ -32,7 +34,13 @@
} catch (error) {
if (acceptedRoutes.includes($page.url.pathname)) {
await goto(`${base}${$page.url.pathname}${$page.url.search}`);
} else await goto(`${base}/login`);
} else {
/**
* Clear cache.
*/
window.sessionStorage.clear();
await goto(`${base}/login`);
}
} finally {
loaded = true;
}
@@ -10,9 +10,6 @@
afterNavigate(handle);
async function handle(event = null) {
if (!$user) {
await user.fetchUser();
}
updateLayout({
navigate: event,
title: $user?.name,
+1 -1
View File
@@ -19,7 +19,7 @@
const login = async () => {
try {
await sdkForConsole.account.createEmailSession(mail, pass);
user.fetchUser();
await user.fetchUser();
addNotification({
type: 'success',
message: 'Successfully logged in.'