Added Client Portal(Working)
Build & Auto-Repair / build (push) Has been cancelled

This commit is contained in:
JCBSComputer
2026-07-01 13:34:58 +02:00
parent 00bda54695
commit 9bfd4e47ee
9 changed files with 461 additions and 42 deletions
+14 -16
View File
@@ -1,4 +1,4 @@
import { NextRequest } from "next/server"
import { NextRequest, NextResponse } from "next/server"
import {
comparePassword,
getUserByEmail,
@@ -15,10 +15,7 @@ import {
import { checkRateLimit } from "@/lib/rate-limit"
function jsonResponse(data: unknown, status: number, headers?: Record<string, string>) {
return new Response(JSON.stringify(data), {
status,
headers: { "Content-Type": "application/json", ...headers },
})
return NextResponse.json(data, { status, headers })
}
export async function POST(request: NextRequest) {
@@ -132,20 +129,21 @@ export async function POST(request: NextRequest) {
const user = mapDbUserToSessionUser(dbUser)
const cookieStr = `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Strict; Path=/; Max-Age=86400${process.env.NODE_ENV === "production" ? "; Secure" : ""}`
return new Response(JSON.stringify({ user }), {
status: 200,
headers: {
"Content-Type": "application/json",
"Set-Cookie": cookieStr,
},
const isHttps = request.nextUrl.protocol === "https:" || request.headers.get("x-forwarded-proto") === "https"
const response = NextResponse.json({ user })
response.cookies.set(SESSION_COOKIE, token, {
httpOnly: true,
sameSite: "strict",
path: "/",
maxAge: 86400,
secure: isHttps,
})
return response
} catch (error) {
console.error("Login error:", error)
return new Response(
JSON.stringify({ error: "Authentication service unavailable." }),
{ status: 503, headers: { "Content-Type": "application/json" } }
return NextResponse.json(
{ error: "Authentication service unavailable." },
{ status: 503 }
)
}
}