feat: routes guard

This commit is contained in:
puriphatt 2024-08-30 12:05:37 +07:00
parent ac1dddf5c3
commit 9558d95fcf

View file

@ -1,4 +1,5 @@
import { RouteRecordRaw } from 'vue-router';
import { isRoleInclude } from 'stores/utils';
const routes: RouteRecordRaw[] = [
{
@ -14,11 +15,41 @@ const routes: RouteRecordRaw[] = [
{
path: '/branch-management',
name: 'BranchManagement',
beforeEnter: (to, from, next) => {
if (
isRoleInclude([
'admin',
'branch_admin',
'head_of_admin',
'system',
'owner',
])
) {
next();
} else {
next('/');
}
},
component: () => import('pages/01_branch-management/MainPage.vue'),
},
{
path: '/personnel-management',
name: 'PersonnelManagement',
beforeEnter: (to, from, next) => {
if (
isRoleInclude([
'admin',
'branch_admin',
'head_of_admin',
'system',
'owner',
])
) {
next();
} else {
next('/');
}
},
component: () => import('pages/02_personnel-management/MainPage.vue'),
},
{