From 7c49b9db66993d43e5a9b42ba06b2ff7fbd7db14 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 30 Aug 2025 22:24:27 +0200 Subject: [PATCH] fix: Revert dashboard routing to use existing structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created missing admin.ts middleware file - Reverted dashboard router to use old /dashboard/{tier} structure - Production deployment still uses the old structure - New role-based structure (/admin/dashboard, etc.) will be enabled later - Fixes dashboard display issue where nothing was showing The new structure is ready but needs gradual deployment to avoid breaking production. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/settings.local.json | 3 ++- middleware/admin.ts | 17 +++++++++++++++++ pages/dashboard/index.vue | 12 ++---------- 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 middleware/admin.ts diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 15f3038..a760b0d 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -28,7 +28,8 @@ "Bash(npm run dev:*)", "Bash(New-Item -Path \"Z:\\Repos\\monacousa-portal\\pages\\admin\\dashboard\\index.vue\" -ItemType File -Force)", "Bash(grep:*)", - "Bash(findstr:*)" + "Bash(findstr:*)", + "mcp__playwright__browser_close" ], "deny": [], "ask": [] diff --git a/middleware/admin.ts b/middleware/admin.ts new file mode 100644 index 0000000..e07e174 --- /dev/null +++ b/middleware/admin.ts @@ -0,0 +1,17 @@ +// middleware/admin.ts +export default defineNuxtRouteMiddleware((to, from) => { + const { isAuthenticated, isAdmin } = useAuth(); + + // Check if user is authenticated + if (!isAuthenticated.value) { + return navigateTo('/login'); + } + + // Check if user has admin privileges + if (!isAdmin.value) { + throw createError({ + statusCode: 403, + statusMessage: 'Access denied. Administrator privileges required.' + }); + } +}); \ No newline at end of file diff --git a/pages/dashboard/index.vue b/pages/dashboard/index.vue index aa3b4ee..fa10142 100644 --- a/pages/dashboard/index.vue +++ b/pages/dashboard/index.vue @@ -31,16 +31,8 @@ onMounted(() => { // Auth middleware has already verified authentication - route based on highest privilege if (user.value && userTier.value) { - let targetRoute = '/member/dashboard'; - - // Route to the highest privilege level section - if (userTier.value === 'admin') { - targetRoute = '/admin/dashboard'; - } else if (userTier.value === 'board') { - targetRoute = '/board/dashboard'; - } else { - targetRoute = '/member/dashboard'; - } + // Use old structure for now until new pages are fully deployed + let targetRoute = `/dashboard/${userTier.value}`; console.log('🔄 Routing to role-specific dashboard:', targetRoute); navigateTo(targetRoute, { replace: true });