From f623cd01798a5336a6ba7cc130229c70f5b7a46e Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski <5760249+gdarko@users.noreply.github.com> Date: Thu, 2 Apr 2026 16:47:16 +0200 Subject: [PATCH] Upgrade vue-router from v4 to v5 (#598) - Migrate beforeEach navigation guard from next() callback to return-based API, preparing for vue-router v6 where next() is removed --- package.json | 2 +- resources/scripts/router/index.js | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) 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' } + } } })