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
This commit is contained in:
kimjaehyeon0101
2025-09-29 17:41:07 +00:00
parent 4a00fd5c1b
commit ccc629cba7
2 changed files with 8 additions and 4 deletions

View File

@ -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 (
<div className="min-h-screen bg-background flex items-center justify-center">
<div className="animate-spin rounded-full h-32 w-32 border-b-2 border-primary"></div>

View File

@ -11,6 +11,10 @@ export default function Home() {
window.location.href = "/api/logout";
};
const handleAdminPage = () => {
window.location.href = "/admin";
};
return (
<div className="min-h-screen bg-gray-50">
{/* Header */}
@ -41,7 +45,7 @@ export default function Home() {
<Button
variant="ghost"
size="sm"
onClick={handleLogout}
onClick={handleAdminPage}
data-testid="button-admin"
>