From 8033038c2e47ec36f4233c4054d6e3365e9e0baa Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Sat, 15 Feb 2025 11:16:52 +0100 Subject: [PATCH] routing permissions --- src/router/adminGuard.ts | 8 ++++---- src/router/index.ts | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/router/adminGuard.ts b/src/router/adminGuard.ts index 33909b5..83d1331 100644 --- a/src/router/adminGuard.ts +++ b/src/router/adminGuard.ts @@ -7,15 +7,15 @@ export async function abilityAndNavUpdate(to: any, from: any, next: any) { const ability = useAbilityStore(); const navigation = useNavigationStore(); + let admin = to.meta.admin || false; let type = to.meta.type; let section = to.meta.section; let module = to.meta.module; - navigation.activeNavigation = to.name.split("-")[1]; - navigation.activeLink = to.name.split("-")[2]; - - if (ability.can(type, section, module)) { + if ((admin && ability.isAdmin()) || ability.can(type, section, module)) { NProgress.done(); + navigation.activeNavigation = to.name.split("-")[1]; + navigation.activeLink = to.name.split("-")[2]; next(); } else { NProgress.done(); diff --git a/src/router/index.ts b/src/router/index.ts index b9ac0fd..2dafa06 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -665,6 +665,8 @@ const router = createRouter({ path: "version", name: "admin-user-version", component: () => import("@/views/admin/management/version/VersionDisplay.vue"), + meta: { admin: true }, + beforeEnter: [abilityAndNavUpdate], }, ], },