Merge branch 'dev' into staging
This commit is contained in:
commit
3320454624
@ -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 };
|
||||
}
|
||||
|
||||
@ -356,14 +356,13 @@ export default class CustomersService extends BaseService {
|
||||
|
||||
private async sendSmsCodeToCustomer(totpPin: number, customer: Customer) {
|
||||
const message = "Votre code de vérification LEcoffre.io est : " + totpPin.toString();
|
||||
|
||||
|
||||
// Sélectionnez le fournisseur de SMS en fonction de la variable d'environnement
|
||||
//const selectedProvider = this.variables.SMS_PROVIDER === "OVH" ? this.ovhService : this.smsFactorService;
|
||||
|
||||
// Envoi du SMS
|
||||
if (!customer.contact?.cell_phone_number) return;
|
||||
let success = await this.ovhService.sendSms(customer.contact?.cell_phone_number, message);
|
||||
|
||||
let success = await this.ovhService.sendSms(customer.contact?.cell_phone_number, message);
|
||||
|
||||
// Si l'envoi échoue, basculez automatiquement sur le second fournisseur
|
||||
if (!success) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user