mirror of https://github.com/MaxLeiter/Drift
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
329 B
TypeScript
18 lines
329 B
TypeScript
import { getCurrentUser } from "@lib/server/session"
|
|
import { redirect } from "next/navigation"
|
|
|
|
export default async function AdminLayout({
|
|
children
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
const user = await getCurrentUser()
|
|
const isAdmin = user?.role === "admin"
|
|
|
|
if (!isAdmin) {
|
|
return redirect("/")
|
|
}
|
|
|
|
return children
|
|
}
|