260218:1712 20260218 TASK-BEFE-001n
All checks were successful
Build and Deploy / deploy (push) Successful in 4m55s
All checks were successful
Build and Deploy / deploy (push) Successful in 4m55s
This commit is contained in:
@@ -1,28 +1,24 @@
|
||||
import { AdminSidebar } from "@/components/admin/sidebar";
|
||||
import { AdminSidebar } from '@/components/admin/sidebar';
|
||||
|
||||
import { auth } from "@/lib/auth";
|
||||
import { auth } from '@/lib/auth';
|
||||
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function AdminLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await auth();
|
||||
|
||||
// Temporary bypass for UI testing
|
||||
const isAdmin = true; // session?.user?.role === 'ADMIN';
|
||||
// Validate Admin or DC role
|
||||
const userRole = session?.user?.role;
|
||||
const isAdmin = userRole === 'ADMIN' || userRole === 'DC';
|
||||
|
||||
if (!session || !isAdmin) {
|
||||
// redirect("/");
|
||||
redirect('/dashboard'); // Redirect unauthorized users to dashboard
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen w-full bg-background">
|
||||
<AdminSidebar />
|
||||
<div className="flex-1 overflow-auto bg-muted/10 p-4">
|
||||
{children}
|
||||
</div>
|
||||
<div className="flex-1 overflow-auto bg-muted/10 p-4">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user