diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 86eb3af..b494b7b 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -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() }) diff --git a/frontend/src/views/AdminDashboardView.vue b/frontend/src/views/AdminDashboardView.vue new file mode 100644 index 0000000..56008b7 --- /dev/null +++ b/frontend/src/views/AdminDashboardView.vue @@ -0,0 +1,24 @@ + + + \ No newline at end of file diff --git a/frontend/src/views/AdminLoginView.vue b/frontend/src/views/AdminLoginView.vue new file mode 100644 index 0000000..14edb69 --- /dev/null +++ b/frontend/src/views/AdminLoginView.vue @@ -0,0 +1,89 @@ + + + \ No newline at end of file