first commit

This commit is contained in:
mstfyldz
2026-08-16 17:18:23 +03:00
commit 5ace6898b6
61 changed files with 12065 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import { NextResponse } from "next/server";
import { validateCredentials, createSessionToken, COOKIE_NAME } from "@/lib/auth";
export async function POST(request: Request) {
try {
const { username, password } = await request.json();
if (!validateCredentials(username, password)) {
return NextResponse.json(
{ error: "Kullanıcı adı veya şifre hatalı!" },
{ status: 401 }
);
}
const token = createSessionToken(username);
const response = NextResponse.json({
success: true,
message: "Giriş başarılı",
username,
});
response.cookies.set({
name: COOKIE_NAME,
value: token,
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "lax",
path: "/",
maxAge: 7 * 24 * 60 * 60, // 7 days
});
return response;
} catch (error) {
console.error("Login error:", error);
return NextResponse.json(
{ error: "Giriş işlemi sırasında sunucu hatası oluştu" },
{ status: 500 }
);
}
}