feat: secu migrate to user uuid

This commit is contained in:
Julien Froidefond
2025-08-21 13:54:13 +02:00
parent ef16c73625
commit 578f0858e8
12 changed files with 532 additions and 70 deletions

View File

@@ -7,11 +7,10 @@ import { COOKIE_NAME } from "@/lib/auth-utils";
export async function GET(request: NextRequest) {
try {
const cookieStore = await cookies();
const userId = cookieStore.get(COOKIE_NAME)?.value;
const userIdNum = userId ? parseInt(userId) : null;
const userUuid = cookieStore.get(COOKIE_NAME)?.value;
// Support pour l'ancien mode avec paramètres (pour la compatibilité)
if (!userIdNum) {
if (!userUuid) {
const { searchParams } = new URL(request.url);
const firstName = searchParams.get("firstName");
const lastName = searchParams.get("lastName");
@@ -29,8 +28,8 @@ export async function GET(request: NextRequest) {
return NextResponse.json({ evaluation });
}
// Mode authentifié par cookie
const userProfile = await evaluationService.getUserById(userIdNum);
// Mode authentifié par cookie UUID
const userProfile = await evaluationService.getUserByUuid(userUuid);
if (!userProfile) {
return NextResponse.json(
{ error: "Utilisateur non trouvé" },