MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / AdminLayout

Function AdminLayout

web/src/app/admin/layout.tsx:14–49  ·  view source on GitHub ↗
({ children }: AdminLayoutProps)

Source from the content-addressed store, hash-verified

12}
13
14export 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}

Callers

nothing calls this directly

Calls 1

redirectFunction · 0.50

Tested by

no test coverage detected