From 1fded57daa6b4e58170d33f1af17ff2b048c442b Mon Sep 17 00:00:00 2001 From: sdraris Date: Fri, 12 Sep 2025 12:32:10 +0200 Subject: [PATCH] gestionnaire service corrected --- .../gestionnaires/gestionnaires.service.ts | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/routes/gestionnaires/gestionnaires.service.ts b/src/routes/gestionnaires/gestionnaires.service.ts index 43929d4..f983458 100644 --- a/src/routes/gestionnaires/gestionnaires.service.ts +++ b/src/routes/gestionnaires/gestionnaires.service.ts @@ -24,24 +24,25 @@ export class GestionnairesService { if (exist) throw new ConflictException('Email déjà utilisé'); const salt = await bcrypt.genSalt(); - const password_hash = await bcrypt.hash(dto.password, salt); + const hashedPassword = await bcrypt.hash(dto.password, salt); const entity = this.gestionnaireRepository.create({ email: dto.email, - password_hash, - first_name: dto.first_name, - last_name: dto.last_name, - gender: dto.gender, - status: dto.status, - phone: dto.phone, - address: dto.address, + password: hashedPassword, + prenom: dto.prenom, + nom: dto.nom, + genre: dto.genre, + statut: dto.statut, + telephone: dto.telephone, + adresse: dto.adresse, photo_url: dto.photo_url, - consent_photo: dto.consent_photo ?? false, - consent_photo_at: dto.consent_photo_at ? new Date(dto.consent_photo_at) : undefined, - must_change_password: dto.must_change_password ?? false, + consentement_photo: dto.consentement_photo ?? false, + date_consentement_photo: dto.date_consentement_photo + ? new Date(dto.date_consentement_photo) + : undefined, + changement_mdp_obligatoire: dto.changement_mdp_obligatoire ?? false, role: RoleType.GESTIONNAIRE, }); - return this.gestionnaireRepository.save(entity); } @@ -66,13 +67,15 @@ export class GestionnairesService { if (dto.password) { const salt = await bcrypt.genSalt(); - gestionnaire.password_hash = await bcrypt.hash(dto.password, salt); + gestionnaire.password = await bcrypt.hash(dto.password, salt); + delete (dto as any).password; } - if (dto.consent_photo_at !== undefined) { - gestionnaire.consent_photo_at = dto.consent_photo_at - ? new Date(dto.consent_photo_at) + if (dto.date_consentement_photo !== undefined) { + gestionnaire.date_consentement_photo = dto.date_consentement_photo + ? new Date(dto.date_consentement_photo) : undefined; + delete (dto as any).date_consentement_photo; } Object.assign(gestionnaire, dto);