diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 07bf177..507a44f 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -22,7 +22,7 @@ export default boot(({ router }) => { /*** * Intercept responses - * - filter 401 --> logout + * - filter 401 --> handleLoggedOut * - filter timeout or 502-504 --> backendOffline */ api.interceptors.response.use( @@ -45,7 +45,7 @@ export default boot(({ router }) => { query: { redirect: next }, }); } else if (e.response && e.response.status == 401) { - void store.logout(); + void store.handleLoggedOut(); if (current.name !== 'login') { await router.push({ name: 'login', diff --git a/src/boot/plugins.ts b/src/boot/plugins.ts index 4966893..ba86449 100644 --- a/src/boot/plugins.ts +++ b/src/boot/plugins.ts @@ -10,7 +10,8 @@ const config: { [key: string]: Array } = { // Do not change required Modules !! requiredModules: ['User'], // here you can import plugins. - loadModules: ['Balance', 'Schedule', 'Pricelist'], + //loadModules: ['Balance', 'Schedule', 'Pricelist'], + loadModules: [], }; /* Stop! diff --git a/src/stores/index.ts b/src/stores/index.ts index c1dd227..681d048 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -76,19 +76,13 @@ export const useMainStore = defineStore({ async logout() { if (!this.session || !this.session.token) return false; - LocalStorage.clear(); - try { const token = this.session.token; await api.delete(`/auth/${token}`); - this.$patch({ - session: undefined, - user: undefined, - }); } catch (error) { return false; } finally { - SessionStorage.clear(); + this.handleLoggedOut( ); } return true; }, @@ -151,6 +145,15 @@ export const useMainStore = defineStore({ async setShortcuts() { await api.put(`users/${this.currentUser.userid}/shortcuts`, this.shortcuts); }, + handleLoggedOut() { + LocalStorage.clear(); + + this.$patch({ + session: undefined, + user: undefined, + }); + SessionStorage.clear(); + }, }, });