diff --git a/src/services/common/OvhService/OvhService.ts b/src/services/common/OvhService/OvhService.ts index 94fb0e05..eaa9196b 100644 --- a/src/services/common/OvhService/OvhService.ts +++ b/src/services/common/OvhService/OvhService.ts @@ -20,6 +20,7 @@ export default class OvhService extends BaseService { ovh.request('POST', '/sms/' + serviceName + '/jobs/', { message: message, sender: "LeCoffre", + senderForResponse: true, receivers: [phoneNumber], }, (error: any, response: any) => { if (error) { diff --git a/src/services/common/SmsFactorService/SmsFactorService.ts b/src/services/common/SmsFactorService/SmsFactorService.ts index 14f93b6b..13332750 100644 --- a/src/services/common/SmsFactorService/SmsFactorService.ts +++ b/src/services/common/SmsFactorService/SmsFactorService.ts @@ -16,12 +16,12 @@ export default class SmsFactorService extends BaseService { phoneNumber + "&sender=LeCoffre&text=" + message + - "token=" + + "&token=" + this.variables.SMS_FACTOR_TOKEN, {}, ) .then((response) => { - console.log("SMS sent successfully via Sms Factor:", response.status); + console.log("SMS sent successfully via Sms Factor :" + response); return true; }) .catch((error) => { diff --git a/src/services/customer/CustomersService/CustomersService.ts b/src/services/customer/CustomersService/CustomersService.ts index 922455f8..7a5789f6 100644 --- a/src/services/customer/CustomersService/CustomersService.ts +++ b/src/services/customer/CustomersService/CustomersService.ts @@ -110,7 +110,7 @@ export default class CustomersService extends BaseService { const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60000), reason); if (!totpCode) return null; // 5: Send the SMS code to the customer - await this.sendSmsCodeToCustomer(totpPin, customer); + if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer); return { customer, totpCode: TotpCodesResource.hydrate({ @@ -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 - 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 * 60000), totpCodeToResend.reason!, true); // 7: Send the SMS code to the customer - await this.sendSmsCodeToCustomer(totpPin, customer); + if(this.variables.ENV !== 'dev') await this.sendSmsCodeToCustomer(totpPin, customer); return { customer, totpCode }; } @@ -355,17 +355,18 @@ 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?.phone_number) return; - let success = await selectedProvider.sendSms(customer.contact?.phone_number, totpPin.toString()); + let success = await selectedProvider.sendSms(customer.contact?.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; - success = await alternateProvider.sendSms(customer.contact?.phone_number, totpPin.toString()); + success = await alternateProvider.sendSms(customer.contact?.phone_number, message); } }