23 lines
589 B
TypeScript
23 lines
589 B
TypeScript
import { getServerSession } from "next-auth";
|
|
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
|
|
import { redirect } from "next/navigation";
|
|
|
|
export default async function AdminLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const session = await getServerSession(authOptions);
|
|
const adminIds = (process.env.ADMIN_DISCORD_IDS ?? "")
|
|
.split(",")
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
const discordId = (session?.user as any)?.discordId;
|
|
|
|
if (!discordId || !adminIds.includes(discordId)) {
|
|
redirect("/");
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}
|