first commit

This commit is contained in:
2026-01-13 18:08:59 +01:00
commit 5d2630a02f
41 changed files with 1632 additions and 0 deletions

15
lib/auth-helpers.ts Normal file
View File

@@ -0,0 +1,15 @@
import { getServerSession } from "next-auth";
import { NextResponse } from "next/server";
import { authOptions } from "./auth";
export async function requireSession() {
const session = await getServerSession(authOptions);
if (!session?.user?.email) {
return { session: null, response: NextResponse.json({ error: "Unauthorized" }, { status: 401 }) };
}
return { session, response: null };
}
export function isAdminSession(session: { user?: { role?: string } } | null) {
return session?.user?.role === "ADMIN";
}