Files
ngo-toolkit/lib/auth.ts
T
2026-03-18 18:26:24 +08:00

11 lines
321 B
TypeScript

import { getSession } from '@auth0/nextjs-auth0';
import { NextResponse } from 'next/server';
export async function requireAdmin(): Promise<NextResponse | null> {
const session = await getSession();
if (!session?.user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
return null;
}