1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

чиним билд08

This commit is contained in:
MoonTestUse1
2025-01-02 02:08:17 +06:00
parent 011b741089
commit bfbe468b56
3 changed files with 126 additions and 9 deletions

View File

@@ -23,26 +23,30 @@ const router = createRouter({
name: 'requests',
component: () => import('@/views/RequestsView.vue'),
meta: { requiresAuth: true }
},
{
path: '/admin/dashboard',
name: 'admin-dashboard',
component: () => import('@/views/AdminDashboardView.vue'),
meta: { requiresAdmin: true }
}
]
});
router.beforeEach((to, from, next) => {
console.log('Проверка маршрута:', to.path)
if (to.meta.requiresAuth) {
console.log('Маршрут требует авторизации')
if (to.meta.requiresAdmin) {
const adminToken = localStorage.getItem('admin_token')
if (!adminToken) {
next('/admin')
return
}
} else if (to.meta.requiresAuth) {
const token = localStorage.getItem('token')
console.log('Токен:', token ? 'Присутствует' : 'Отсутствует')
if (!token) {
console.log('Перенаправление на /login')
next('/login')
return
}
}
console.log('Разрешаем переход')
next()
})