gestionnaire service corrected
This commit is contained in:
parent
6c2ebe9cab
commit
1fded57daa
@ -24,24 +24,25 @@ export class GestionnairesService {
|
|||||||
if (exist) throw new ConflictException('Email déjà utilisé');
|
if (exist) throw new ConflictException('Email déjà utilisé');
|
||||||
|
|
||||||
const salt = await bcrypt.genSalt();
|
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({
|
const entity = this.gestionnaireRepository.create({
|
||||||
email: dto.email,
|
email: dto.email,
|
||||||
password_hash,
|
password: hashedPassword,
|
||||||
first_name: dto.first_name,
|
prenom: dto.prenom,
|
||||||
last_name: dto.last_name,
|
nom: dto.nom,
|
||||||
gender: dto.gender,
|
genre: dto.genre,
|
||||||
status: dto.status,
|
statut: dto.statut,
|
||||||
phone: dto.phone,
|
telephone: dto.telephone,
|
||||||
address: dto.address,
|
adresse: dto.adresse,
|
||||||
photo_url: dto.photo_url,
|
photo_url: dto.photo_url,
|
||||||
consent_photo: dto.consent_photo ?? false,
|
consentement_photo: dto.consentement_photo ?? false,
|
||||||
consent_photo_at: dto.consent_photo_at ? new Date(dto.consent_photo_at) : undefined,
|
date_consentement_photo: dto.date_consentement_photo
|
||||||
must_change_password: dto.must_change_password ?? false,
|
? new Date(dto.date_consentement_photo)
|
||||||
|
: undefined,
|
||||||
|
changement_mdp_obligatoire: dto.changement_mdp_obligatoire ?? false,
|
||||||
role: RoleType.GESTIONNAIRE,
|
role: RoleType.GESTIONNAIRE,
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.gestionnaireRepository.save(entity);
|
return this.gestionnaireRepository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,13 +67,15 @@ export class GestionnairesService {
|
|||||||
|
|
||||||
if (dto.password) {
|
if (dto.password) {
|
||||||
const salt = await bcrypt.genSalt();
|
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) {
|
if (dto.date_consentement_photo !== undefined) {
|
||||||
gestionnaire.consent_photo_at = dto.consent_photo_at
|
gestionnaire.date_consentement_photo = dto.date_consentement_photo
|
||||||
? new Date(dto.consent_photo_at)
|
? new Date(dto.date_consentement_photo)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
delete (dto as any).date_consentement_photo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(gestionnaire, dto);
|
Object.assign(gestionnaire, dto);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user