From ccc629cba7d8978ea6aa444173a2ac0a3a6f8556 Mon Sep 17 00:00:00 2001 From: kimjaehyeon0101 <47347352-kimjaehyeon0101@users.noreply.replit.com> Date: Mon, 29 Sep 2025 17:41:07 +0000 Subject: [PATCH] Allow super administrators to access the admin dashboard Update `AdminDashboard.tsx` to include 'superadmin' role for access. Modify `Home.tsx` to navigate to '/admin' when the admin button is clicked. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 069d4324-6c40-4355-955e-c714a50de1ea Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/069d4324-6c40-4355-955e-c714a50de1ea/LZrXNFV --- client/src/pages/AdminDashboard.tsx | 6 +++--- client/src/pages/Home.tsx | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/pages/AdminDashboard.tsx b/client/src/pages/AdminDashboard.tsx index 93e295a..3014098 100644 --- a/client/src/pages/AdminDashboard.tsx +++ b/client/src/pages/AdminDashboard.tsx @@ -10,9 +10,9 @@ export default function AdminDashboard() { const { user, isLoading } = useAuth(); const { toast } = useToast(); - // Redirect if not authenticated or not admin + // Redirect if not authenticated or not admin/superadmin useEffect(() => { - if (!isLoading && (!user || user.role !== 'admin')) { + if (!isLoading && (!user || (user.role !== 'admin' && user.role !== 'superadmin'))) { toast({ title: "Unauthorized", description: "You don't have permission to access this page.", @@ -47,7 +47,7 @@ export default function AdminDashboard() { window.location.href = "/api/logout"; }; - if (isLoading || !user || user.role !== 'admin') { + if (isLoading || !user || (user.role !== 'admin' && user.role !== 'superadmin')) { return (
diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx index 5126b6d..3063286 100644 --- a/client/src/pages/Home.tsx +++ b/client/src/pages/Home.tsx @@ -11,6 +11,10 @@ export default function Home() { window.location.href = "/api/logout"; }; + const handleAdminPage = () => { + window.location.href = "/admin"; + }; + return (
{/* Header */} @@ -41,7 +45,7 @@ export default function Home() {