routing permissions

This commit is contained in:
Julian Krauser 2025-02-15 11:16:52 +01:00
parent 1d2e113c4b
commit 8033038c2e
2 changed files with 6 additions and 4 deletions

View file

@ -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();

View file

@ -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],
},
],
},