Merge branch 'dev' into staging

This commit is contained in:
Maxime Lalo 2023-12-15 16:03:37 +01:00
commit 3320454624

View File

@ -12,43 +12,43 @@ import SmsFactorService from "@Services/common/SmsFactorService/SmsFactorService
export class SmsNotExpiredError extends Error {
constructor() {
super("SMS code not expired");
super("Code déjà envoyé");
}
}
export class TotpCodeExpiredError extends Error {
constructor() {
super("Totp code not found or expired");
super("Code non trouvé ou expiré");
}
}
export class InvalidTotpCodeError extends Error {
constructor() {
super("Invalid Totp code");
super("Code invalide");
}
}
export class NotRegisteredCustomerError extends Error {
constructor() {
super("Customer not registered");
super("Ce client n'existe pas");
}
}
export class InvalidPasswordError extends Error {
constructor() {
super("Invalid password");
super("Mot de passe incorrect");
}
}
export class PasswordAlreadySetError extends Error {
constructor() {
super("Password already set");
super("Le mot de passe a déjà été défini");
}
}
export class TooSoonForNewCode extends Error {
constructor() {
super("You need to wait at least 30 seconds before asking for a new code");
super("Vous devez attendre 30 secondes avant de pouvoir demander un nouveau code");
}
}
@Service()
@ -110,7 +110,7 @@ export default class CustomersService extends BaseService {
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), reason);
if (!totpCode) return null;
// 5: Send the SMS code to the customer
if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer);
if (this.variables.ENV !== "dev") await this.sendSmsCodeToCustomer(totpPin, customer);
return {
customer,
totpCode: TotpCodesResource.hydrate<TotpCodesResource>({
@ -162,7 +162,7 @@ export default class CustomersService extends BaseService {
await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60000), TotpCodesReasons.RESET_PASSWORD);
// 5: Send the SMS code to the customer
if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer);
if (this.variables.ENV !== "dev") await this.sendSmsCodeToCustomer(totpPin, customer);
return customer;
}
@ -292,7 +292,7 @@ export default class CustomersService extends BaseService {
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), totpCodeToResend.reason!, true);
// 7: Send the SMS code to the customer
if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer);
if (this.variables.ENV !== "dev") await this.sendSmsCodeToCustomer(totpPin, customer);
return { customer, totpCode };
}
@ -364,7 +364,6 @@ export default class CustomersService extends BaseService {
if (!customer.contact?.cell_phone_number) return;
let success = await this.ovhService.sendSms(customer.contact?.cell_phone_number, message);
// Si l'envoi échoue, basculez automatiquement sur le second fournisseur
if (!success) {
//const alternateProvider = this.variables.SMS_PROVIDER === "OVH" ? this.smsFactorService : this.ovhService;