auth service corrected
This commit is contained in:
parent
a783c1a829
commit
e038cab520
@ -46,12 +46,12 @@ export class AuthService {
|
|||||||
const user = await this.usersService.findByEmailOrNull(dto.email);
|
const user = await this.usersService.findByEmailOrNull(dto.email);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new UnauthorizedException('Identifiants invalides');
|
throw new UnauthorizedException('Email invalide');
|
||||||
}
|
}
|
||||||
|
|
||||||
const isMatch = await bcrypt.compare(dto.password, user.password_hash);
|
const isMatch = await bcrypt.compare(dto.password, user.password);
|
||||||
if (!isMatch) {
|
if (!isMatch) {
|
||||||
throw new UnauthorizedException('Identifiants invalides');
|
throw new UnauthorizedException('Mot de passe invalide');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.generateTokens(user.id, user.email, user.role);
|
return this.generateTokens(user.id, user.email, user.role);
|
||||||
@ -95,14 +95,14 @@ export class AuthService {
|
|||||||
registerDto.role = RoleType.PARENT;
|
registerDto.role = RoleType.PARENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerDto.status = StatutUtilisateurType.EN_ATTENTE;
|
registerDto.statut = StatutUtilisateurType.EN_ATTENTE;
|
||||||
|
|
||||||
if (!registerDto.consent_photo) {
|
if (!registerDto.consentement_photo) {
|
||||||
registerDto.consent_photo_at = null;
|
registerDto.date_consentement_photo = null;
|
||||||
} else if (registerDto.consent_photo_at) {
|
} else if (registerDto.date_consentement_photo) {
|
||||||
const date = new Date(registerDto.consent_photo_at);
|
const date = new Date(registerDto.date_consentement_photo);
|
||||||
if (isNaN(date.getTime())) {
|
if (isNaN(date.getTime())) {
|
||||||
registerDto.consent_photo_at = null;
|
registerDto.date_consentement_photo = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,11 +116,10 @@ export class AuthService {
|
|||||||
id: user.id,
|
id: user.id,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
role: user.role,
|
role: user.role,
|
||||||
first_name: user.first_name,
|
prenom: user.prenom,
|
||||||
last_name: user.last_name,
|
nom: user.nom,
|
||||||
status: user.status,
|
statut: user.statut,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user