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;