26 lines
643 B
TypeScript
26 lines
643 B
TypeScript
import { getServerSession } from "next-auth";
|
|
import { authOptions } from "@/lib/auth/auth-options";
|
|
import { redirect } from "next/navigation";
|
|
import { getAdminDiscordIds, getSessionDiscordId } from "@/lib/auth/auth";
|
|
import { PageProgress } from "@/components/page-progress";
|
|
|
|
export default async function AdminLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const session = await getServerSession(authOptions);
|
|
const discordId = getSessionDiscordId(session);
|
|
|
|
if (!discordId || !getAdminDiscordIds().includes(discordId)) {
|
|
redirect("/");
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<PageProgress />
|
|
{children}
|
|
</>
|
|
);
|
|
}
|