使用openai进行了代码review
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { getSessionCookieName, verifySessionToken } from "@/lib/session";
|
||||
|
||||
export async function requireApiAuth(): Promise<NextResponse | null> {
|
||||
const cookieStore = await cookies();
|
||||
const authCookie = cookieStore.get(getSessionCookieName());
|
||||
const isAuthenticated = authCookie ? await verifySessionToken(authCookie.value) : false;
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user