diff --git a/package.json b/package.json index c91c4fc7..240fc816 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "vue": "^3.5", "vue-flatpickr-component": "^11.0.5", "vue-i18n": "^11.0.1", - "vue-router": "^4.5.0", + "vue-router": "^5.0.0", "vuedraggable": "^4.1.0" } } diff --git a/resources/scripts/router/index.js b/resources/scripts/router/index.js index 1de56fe4..4e52f2b6 100644 --- a/resources/scripts/router/index.js +++ b/resources/scripts/router/index.js @@ -17,22 +17,20 @@ const router = createRouter({ routes, }) -router.beforeEach((to, from, next) => { +router.beforeEach((to) => { const userStore = useUserStore() const globalStore = useGlobalStore() let ability = to.meta.ability const { isAppLoaded } = globalStore if (ability && isAppLoaded && to.meta.requiresAuth) { - if (userStore.hasAbilities(ability)) { - next() - } else next({ name: 'account.settings' }) + if (!userStore.hasAbilities(ability)) { + return { name: 'account.settings' } + } } else if (to.meta.isOwner && isAppLoaded) { - if (userStore.currentUser.is_owner) { - next() - } else next({ name: 'dashboard' }) - } else { - next() + if (!userStore.currentUser.is_owner) { + return { name: 'dashboard' } + } } })