forked from Ynov/ptitspas-ynov-back
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é');
|
||||
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user