From 8f730da963ef759725a33cce203c41edd1bd594f Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 17 Apr 2024 09:57:46 +0200 Subject: [PATCH] Fixed wrong redirection --- frontend/src/App.vue | 5 ----- frontend/src/router/index.js | 5 ++++- frontend/src/stores/auth.store.js | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 461abade6..d372e964f 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -3,9 +3,4 @@ diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 7efefe625..5420cd0d6 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -294,11 +294,14 @@ const router = createRouter({ routes, }) -router.beforeEach((to, from, next) => { +router.beforeEach(async (to, from, next) => { if (to.meta.requiresAuth !== undefined) { const previousPage = window.location.href sessionStorage.setItem('previousPage', previousPage) const authStore = useAuthStore() + if (!authStore.authUser) { + await authStore.initialize() + } authStore.validateAccess() if (to.meta.allowedRoles !== undefined) { if (to.meta.allowedRoles.indexOf(authStore.authUser.role) === -1) { diff --git a/frontend/src/stores/auth.store.js b/frontend/src/stores/auth.store.js index 6ec9bec7b..0919efa1b 100644 --- a/frontend/src/stores/auth.store.js +++ b/frontend/src/stores/auth.store.js @@ -11,7 +11,7 @@ import accountApi from '@/api/account' import accountsApi from '@/api/accounts' export const useAuthStore = defineStore('auth', () => { - const authUser = ref({}) + const authUser = ref(null) const isAuthenticated = ref(false) const manager = new UserManager({ authority: 'http://localhost:8000/api/o',