From 48efd2117860ce4f61476587b02b3ba55bc5e811 Mon Sep 17 00:00:00 2001 From: Spythere Date: Sat, 16 Sep 2023 18:34:59 +0200 Subject: [PATCH] fix routingu --- src/App.vue | 5 +++++ src/store.ts | 3 ++- src/views/LoginView.vue | 24 +++++++++++------------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/App.vue b/src/App.vue index 691c3ac..d358d12 100644 --- a/src/App.vue +++ b/src/App.vue @@ -32,6 +32,8 @@ export default defineComponent({ methods: { async autoLogin() { try { + this.store.authState = AuthState.LOADING; + const response = await axios.post( '/auth/token', {}, @@ -42,9 +44,12 @@ export default defineComponent({ ); this.store.user = response.data; + this.store.authState = AuthState.AUTHORIZED; + this.$router.push('/'); } catch (error) { this.$router.push('/login'); + this.store.authState = AuthState.UNAUTHORIZED; } }, }, diff --git a/src/store.ts b/src/store.ts index bd33197..47bb89d 100644 --- a/src/store.ts +++ b/src/store.ts @@ -14,12 +14,13 @@ export const useStore = defineStore('store', { stationList: [], backupList: [], stationsToRemove: [], - searchedSceneryName: '', changeList: [], newStationsCount: 0, routesModalVisible: true, currentStation: null, + searchedSceneryName: '', selectedStationName: '', + user: null, notifyDiscord: true, diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index 867ff19..e723326 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -1,5 +1,5 @@