로그인 UI 추가

This commit is contained in:
koreacomp5
2025-10-10 11:22:43 +09:00
parent c28698cd5c
commit 7ba8091ab9
5 changed files with 95 additions and 2 deletions

View File

@@ -4,6 +4,23 @@ import prisma from "@/lib/prisma";
import { verifyPassword } from "@/lib/password";
import { getClientKey, isRateLimited } from "@/lib/ratelimit";
export async function GET(req: Request) {
try {
const cookieHeader = req.headers.get("cookie") || "";
const uid = cookieHeader
.split(";")
.map((s) => s.trim())
.find((pair) => pair.startsWith("uid="))
?.split("=")[1];
if (!uid) return NextResponse.json({ ok: false }, { status: 200 });
const user = await prisma.user.findUnique({ where: { userId: decodeURIComponent(uid) } });
if (!user) return NextResponse.json({ ok: false }, { status: 200 });
return NextResponse.json({ ok: true, user: { userId: user.userId, nickname: user.nickname } });
} catch {
return NextResponse.json({ ok: false }, { status: 200 });
}
}
export async function POST(req: Request) {
const key = getClientKey(req, "login");
if (isRateLimited(key, 5, 60_000)) {