- 관리자 페이지/스토어/API 삭제(adminAuth·adminMembers·adminStats·AdminLayout·pages/admin) - 라우터에서 /admin 경로·관리자 가드 제거 (사용자 앱 라우팅만 유지) - 공용 저수준(http put/del 등)은 dogs API 등이 사용하므로 유지 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||||
import MainLayout from '@/layouts/MainLayout.vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useAdminAuthStore } from '@/stores/adminAuth'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
@@ -18,35 +17,6 @@ const routes: RouteRecordRaw[] = [
|
||||
{ path: 'profile', name: 'profile', component: () => import('@/pages/ProfilePage.vue') },
|
||||
],
|
||||
},
|
||||
// 관리자 콘솔 (웹 전용) — 사용자 앱과 분리
|
||||
{
|
||||
path: '/admin/login',
|
||||
name: 'admin-login',
|
||||
component: () => import('@/pages/admin/AdminLoginPage.vue'),
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
component: () => import('@/layouts/AdminLayout.vue'),
|
||||
meta: { requiresAdmin: true },
|
||||
children: [
|
||||
{ path: '', redirect: { name: 'admin-dashboard' } },
|
||||
{
|
||||
path: 'dashboard',
|
||||
name: 'admin-dashboard',
|
||||
component: () => import('@/pages/admin/AdminDashboardPage.vue'),
|
||||
},
|
||||
{
|
||||
path: 'members',
|
||||
name: 'admin-members',
|
||||
component: () => import('@/pages/admin/AdminMembersPage.vue'),
|
||||
},
|
||||
{
|
||||
path: 'members/:id',
|
||||
name: 'admin-member-detail',
|
||||
component: () => import('@/pages/admin/AdminMemberDetailPage.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
@@ -56,10 +26,6 @@ const router = createRouter({
|
||||
|
||||
// 소셜 로그인 전용 앱: 미로그인 시 보호 경로 접근 → 로그인으로
|
||||
router.beforeEach((to) => {
|
||||
// 관리자 경로는 아래 관리자 가드가 처리 (사용자 가드는 관여하지 않음)
|
||||
if (to.matched.some((r) => r.meta.requiresAdmin) || to.name === 'admin-login') {
|
||||
return true
|
||||
}
|
||||
const auth = useAuthStore()
|
||||
if (to.meta.requiresAuth && !auth.isAuthenticated) {
|
||||
return { name: 'login', query: { redirect: to.fullPath } }
|
||||
@@ -69,22 +35,4 @@ router.beforeEach((to) => {
|
||||
}
|
||||
})
|
||||
|
||||
// 관리자 콘솔 가드 — 토큰/회원 복원 후 ADMIN 여부 확인 (사용자 인증과 분리)
|
||||
router.beforeEach(async (to) => {
|
||||
const needsAdmin = to.matched.some((r) => r.meta.requiresAdmin)
|
||||
if (!needsAdmin && to.name !== 'admin-login') return true
|
||||
|
||||
const admin = useAdminAuthStore()
|
||||
if (admin.hasToken() && !admin.member) {
|
||||
await admin.fetchMe()
|
||||
}
|
||||
if (needsAdmin && !admin.isAdmin) {
|
||||
return { name: 'admin-login' }
|
||||
}
|
||||
if (to.name === 'admin-login' && admin.isAdmin) {
|
||||
return { name: 'admin-dashboard' }
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user