11 lines
321 B
TypeScript
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;
|
|
}
|