This commit is contained in:
eric
2026-03-13 03:43:50 -05:00
parent e5d080c202
commit 857380aa01
29 changed files with 3595 additions and 580 deletions

View File

@@ -0,0 +1,19 @@
/**
* 从 Cookie 读取邮箱(不调用 PB用于 emailLinked=1 但 userName 被覆盖的场景
*/
import { NextRequest, NextResponse } from "next/server";
import { COOKIE_NAME } from "@/app/lib/auth-cookie";
export async function GET(request: NextRequest) {
const cookie = request.cookies.get(COOKIE_NAME)?.value;
if (!cookie) {
return NextResponse.json({ ok: true, email: null });
}
try {
const payload = JSON.parse(Buffer.from(cookie, "base64url").toString("utf-8"));
const email = payload?.email ?? null;
return NextResponse.json({ ok: true, email: typeof email === "string" ? email : null });
} catch {
return NextResponse.json({ ok: true, email: null });
}
}