diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 9b47874..4e11b15 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -1,4 +1,5 @@ import AppLayout from '@/layout/AppLayout.vue'; +import { useProfileStore } from '@/stores/profile'; import { createRouter, createWebHistory } from 'vue-router'; import Forget from '@/views/Forget.vue'; @@ -100,4 +101,19 @@ const router = createRouter({ ] }); +router.beforeEach((to, from, next) => { + const profileStore = useProfileStore(); + if (to.path.startsWith('/admin')) { + if (!profileStore.isAdmin && !profileStore.isSuperAdmin) { + next({ name: 'not-found' }); + return; + } + if ((to.path.endsWith('servers') || to.path.endsWith('settings')) && !profileStore.isSuperAdmin) { + next({ name: 'not-found' }); + return; + } + } + next(); +}); + export default router;