({ children }: AdminLayoutProps)
| 12 | } |
| 13 | |
| 14 | export default async function AdminLayout({ children }: AdminLayoutProps) { |
| 15 | const session = await getServerSession(authOptions) |
| 16 | |
| 17 | // Check if user is authenticated |
| 18 | if (!session) { |
| 19 | redirect('/login') |
| 20 | } |
| 21 | |
| 22 | // Check if user is admin using the internal utility |
| 23 | const adminUser = await utils.checkSessionIsAdmin(session) |
| 24 | |
| 25 | if (!adminUser) { |
| 26 | return ( |
| 27 | <div className="container mx-auto py-6 px-4"> |
| 28 | <div className="max-w-md mx-auto"> |
| 29 | <Card> |
| 30 | <CardHeader> |
| 31 | <CardTitle>Access Denied</CardTitle> |
| 32 | </CardHeader> |
| 33 | <CardContent> |
| 34 | <p className="mb-4"> |
| 35 | You must be a Codebuff admin to access this page. |
| 36 | </p> |
| 37 | <Link href="/"> |
| 38 | <Button>Go Home</Button> |
| 39 | </Link> |
| 40 | </CardContent> |
| 41 | </Card> |
| 42 | </div> |
| 43 | </div> |
| 44 | ) |
| 45 | } |
| 46 | |
| 47 | // Admin user - render children |
| 48 | return <>{children}</> |
| 49 | } |
nothing calls this directly
no test coverage detected