✨ Errors in french for front
This commit is contained in:
parent
f6f6168afe
commit
67dfcaec5f
@ -12,43 +12,43 @@ import SmsFactorService from "@Services/common/SmsFactorService/SmsFactorService
|
|||||||
|
|
||||||
export class SmsNotExpiredError extends Error {
|
export class SmsNotExpiredError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("SMS code not expired");
|
super("Code déjà envoyé");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TotpCodeExpiredError extends Error {
|
export class TotpCodeExpiredError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Totp code not found or expired");
|
super("Code non trouvé ou expiré");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InvalidTotpCodeError extends Error {
|
export class InvalidTotpCodeError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Invalid Totp code");
|
super("Code invalide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NotRegisteredCustomerError extends Error {
|
export class NotRegisteredCustomerError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Customer not registered");
|
super("Ce client n'existe pas");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InvalidPasswordError extends Error {
|
export class InvalidPasswordError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Invalid password");
|
super("Mot de passe incorrect");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PasswordAlreadySetError extends Error {
|
export class PasswordAlreadySetError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Password already set");
|
super("Le mot de passe a déjà été défini");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TooSoonForNewCode extends Error {
|
export class TooSoonForNewCode extends Error {
|
||||||
constructor() {
|
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()
|
@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);
|
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), reason);
|
||||||
if (!totpCode) return null;
|
if (!totpCode) return null;
|
||||||
// 5: Send the SMS code to the customer
|
// 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 {
|
return {
|
||||||
customer,
|
customer,
|
||||||
totpCode: TotpCodesResource.hydrate<TotpCodesResource>({
|
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);
|
await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60000), TotpCodesReasons.RESET_PASSWORD);
|
||||||
|
|
||||||
// 5: Send the SMS code to the customer
|
// 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;
|
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);
|
const totpCode = await this.saveTotpPin(customer, totpPin, new Date(now + 5 * 60 * 1000), totpCodeToResend.reason!, true);
|
||||||
|
|
||||||
// 7: Send the SMS code to the customer
|
// 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 };
|
return { customer, totpCode };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,14 +356,13 @@ export default class CustomersService extends BaseService {
|
|||||||
|
|
||||||
private async sendSmsCodeToCustomer(totpPin: number, customer: Customer) {
|
private async sendSmsCodeToCustomer(totpPin: number, customer: Customer) {
|
||||||
const message = "Votre code de vérification LEcoffre.io est : " + totpPin.toString();
|
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
|
// Sélectionnez le fournisseur de SMS en fonction de la variable d'environnement
|
||||||
//const selectedProvider = this.variables.SMS_PROVIDER === "OVH" ? this.ovhService : this.smsFactorService;
|
//const selectedProvider = this.variables.SMS_PROVIDER === "OVH" ? this.ovhService : this.smsFactorService;
|
||||||
|
|
||||||
// Envoi du SMS
|
// Envoi du SMS
|
||||||
if (!customer.contact?.cell_phone_number) return;
|
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
|
// Si l'envoi échoue, basculez automatiquement sur le second fournisseur
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user