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:
@ -10,9 +10,9 @@ export default function AdminDashboard() {
|
|||||||
const { user, isLoading } = useAuth();
|
const { user, isLoading } = useAuth();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
// Redirect if not authenticated or not admin
|
// Redirect if not authenticated or not admin/superadmin
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading && (!user || user.role !== 'admin')) {
|
if (!isLoading && (!user || (user.role !== 'admin' && user.role !== 'superadmin'))) {
|
||||||
toast({
|
toast({
|
||||||
title: "Unauthorized",
|
title: "Unauthorized",
|
||||||
description: "You don't have permission to access this page.",
|
description: "You don't have permission to access this page.",
|
||||||
@ -47,7 +47,7 @@ export default function AdminDashboard() {
|
|||||||
window.location.href = "/api/logout";
|
window.location.href = "/api/logout";
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading || !user || user.role !== 'admin') {
|
if (isLoading || !user || (user.role !== 'admin' && user.role !== 'superadmin')) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background flex items-center justify-center">
|
<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>
|
<div className="animate-spin rounded-full h-32 w-32 border-b-2 border-primary"></div>
|
||||||
|
|||||||
@ -11,6 +11,10 @@ export default function Home() {
|
|||||||
window.location.href = "/api/logout";
|
window.location.href = "/api/logout";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAdminPage = () => {
|
||||||
|
window.location.href = "/admin";
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50">
|
<div className="min-h-screen bg-gray-50">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@ -41,7 +45,7 @@ export default function Home() {
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={handleLogout}
|
onClick={handleAdminPage}
|
||||||
data-testid="button-admin"
|
data-testid="button-admin"
|
||||||
>
|
>
|
||||||
관리자 페이지
|
관리자 페이지
|
||||||
|
|||||||
Reference in New Issue
Block a user