Fixed wrong redirection

This commit is contained in:
Antoine Nguyen
2024-06-22 19:44:54 +02:00
committed by Spitfireap
parent 8a4a920afe
commit 8f730da963
3 changed files with 5 additions and 7 deletions
-5
View File
@@ -3,9 +3,4 @@
</template>
<script setup>
import { useAuthStore } from '@/stores'
const authStore = useAuthStore()
authStore.initialize()
</script>
+4 -1
View File
@@ -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) {
+1 -1
View File
@@ -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',