Initial commit

This commit is contained in:
twotalesanimation
2026-06-11 10:46:09 +02:00
commit 81ad7e4ea9
223 changed files with 39530 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
// lib/admin-check.ts
import { getServerSession } from 'next-auth';
import { authOptions } from './auth-options';
export async function requireAdmin() {
const session = await getServerSession(authOptions);
if (!session?.user?.email) throw { status: 401, message: 'Unauthorized' };
const role = (session as any).user.role ?? 'user';
if (!(role === 'admin' || role === 'superadmin')) throw { status: 403, message: 'Forbidden' };
return session;
}