From d69768806c8011fc932f54acd0f2c4350f2ba4c1 Mon Sep 17 00:00:00 2001 From: Julien Martin Date: Sun, 12 Apr 2026 21:37:47 +0200 Subject: [PATCH] =?UTF-8?q?fix(auth):=20inscription=20AM=20=E2=80=94=20per?= =?UTF-8?q?sister=20photo=20si=20photo=5Fbase64=20sans=20photo=5Ffilename?= =?UTF-8?q?=20(#120)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Défaut nom fichier photo_am.jpg ; extension finale dérivée du data-URL - Swagger DTO + description endpoint register/am Made-with: Cursor --- backend/src/routes/auth/auth.controller.ts | 3 ++- backend/src/routes/auth/auth.service.ts | 7 +++++-- backend/src/routes/auth/dto/register-am-complet.dto.ts | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/backend/src/routes/auth/auth.controller.ts b/backend/src/routes/auth/auth.controller.ts index 258d853..ccec2a4 100644 --- a/backend/src/routes/auth/auth.controller.ts +++ b/backend/src/routes/auth/auth.controller.ts @@ -59,7 +59,8 @@ export class AuthController { @Post('register/am') @ApiOperation({ summary: 'Inscription Assistante Maternelle COMPLÈTE', - description: 'Crée User AM + entrée assistantes_maternelles (identité + infos pro + photo + CGU) en une transaction', + description: + 'Crée User AM + entrée assistantes_maternelles (identité + infos pro + photo + CGU) en une transaction. Si photo_base64 est fourni sans photo_filename, le serveur utilise le nom par défaut photo_am.jpg (extension du fichier stocké = type du data-URL).', }) @ApiResponse({ status: 201, description: 'Inscription réussie - Dossier en attente de validation' }) @ApiResponse({ status: 400, description: 'Données invalides ou CGU non acceptées' }) diff --git a/backend/src/routes/auth/auth.service.ts b/backend/src/routes/auth/auth.service.ts index 2665721..5365d7e 100644 --- a/backend/src/routes/auth/auth.service.ts +++ b/backend/src/routes/auth/auth.service.ts @@ -465,8 +465,11 @@ export class AuthService { dateExpiration.setDate(dateExpiration.getDate() + joursExpirationToken); let urlPhoto: string | null = null; - if (dto.photo_base64 && dto.photo_filename) { - urlPhoto = await this.sauvegarderPhotoDepuisBase64(dto.photo_base64, dto.photo_filename); + const photoB64 = (dto.photo_base64 ?? '').trim(); + if (photoB64) { + const nomFichier = + (dto.photo_filename ?? '').trim() || 'photo_am.jpg'; + urlPhoto = await this.sauvegarderPhotoDepuisBase64(photoB64, nomFichier); } const dateConsentementPhoto = diff --git a/backend/src/routes/auth/dto/register-am-complet.dto.ts b/backend/src/routes/auth/dto/register-am-complet.dto.ts index 5800bdd..833602d 100644 --- a/backend/src/routes/auth/dto/register-am-complet.dto.ts +++ b/backend/src/routes/auth/dto/register-am-complet.dto.ts @@ -76,7 +76,12 @@ export class RegisterAMCompletDto { @IsString() photo_base64?: string; - @ApiProperty({ example: 'photo_profil.jpg', required: false }) + @ApiProperty({ + example: 'photo_profil.jpg', + required: false, + description: + 'Nom du fichier photo (optionnel si photo_base64 est fourni ; défaut serveur : photo_am.jpg). L’extension réelle du fichier stocké suit le type MIME du data-URL.', + }) @IsOptional() @IsString() photo_filename?: string;