From 6997e13d28022ccafb530b4ce83658302e4cdec6 Mon Sep 17 00:00:00 2001 From: Vins Date: Wed, 13 Dec 2023 10:20:24 +0100 Subject: [PATCH 1/4] removed logs --- src/services/common/IdNotService/IdNotService.ts | 5 +---- src/services/common/OvhService/OvhService.ts | 1 - src/services/common/SmsFactorService/SmsFactorService.ts | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/services/common/IdNotService/IdNotService.ts b/src/services/common/IdNotService/IdNotService.ts index d5a0eac8..5f9f9fda 100644 --- a/src/services/common/IdNotService/IdNotService.ts +++ b/src/services/common/IdNotService/IdNotService.ts @@ -120,10 +120,7 @@ export default class IdNotService extends BaseService { redirect_uri: this.variables.IDNOT_REDIRECT_URL, code: code, grant_type: "authorization_code", - }); - - console.log(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query); - + }); const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" }); if(token.status !== 200) console.error(await token.text()); diff --git a/src/services/common/OvhService/OvhService.ts b/src/services/common/OvhService/OvhService.ts index f6550900..79036fcb 100644 --- a/src/services/common/OvhService/OvhService.ts +++ b/src/services/common/OvhService/OvhService.ts @@ -27,7 +27,6 @@ export default class OvhService extends BaseService { console.error('Error sending Ovh Sms'); return false; } else { - console.log('SMS sent successfully via Ovh'); return true; } }); diff --git a/src/services/common/SmsFactorService/SmsFactorService.ts b/src/services/common/SmsFactorService/SmsFactorService.ts index 1bc3f714..c756ca3d 100644 --- a/src/services/common/SmsFactorService/SmsFactorService.ts +++ b/src/services/common/SmsFactorService/SmsFactorService.ts @@ -21,7 +21,6 @@ export default class SmsFactorService extends BaseService { {}, ) .then((response) => { - console.log("SMS sent successfully via Sms Factor"); return true; }) .catch((error) => { From a6bdd8708867b2947ed1bbe9cd34f7f240bbefeb Mon Sep 17 00:00:00 2001 From: Vins Date: Fri, 15 Dec 2023 13:16:45 +0100 Subject: [PATCH 2/4] done --- package.json | 2 +- src/app/api/admin/CustomersController.ts | 4 +++- src/app/api/notary/CustomersController.ts | 2 ++ src/app/api/super-admin/CustomersController.ts | 4 +++- src/app/middlewares/AuthHandler.ts | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e9f75855..162504e4 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "file-type-checker": "^1.0.8", "fp-ts": "^2.16.1", "jsonwebtoken": "^9.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.104", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.105", "module-alias": "^2.2.2", "monocle-ts": "^2.3.13", "multer": "^1.4.5-lts.1", diff --git a/src/app/api/admin/CustomersController.ts b/src/app/api/admin/CustomersController.ts index 90e05691..8a81eaa6 100644 --- a/src/app/api/admin/CustomersController.ts +++ b/src/app/api/admin/CustomersController.ts @@ -56,7 +56,7 @@ export default class CustomersController extends ApiController { /** * @description Create a new customer */ - @Post("/api/v1/notary/customers", [authHandler, ruleHandler]) + @Post("/api/v1/admin/customers", [authHandler, ruleHandler]) protected async post(req: Request, response: Response) { try { //init IUser resource with request body values @@ -69,6 +69,8 @@ export default class CustomersController extends ApiController { return; } + if (!customerEntity.contact?.cell_phone_number) return; + const customers = await this.customersService.get({ where: { contact: { email: customerEntity.contact?.email }, diff --git a/src/app/api/notary/CustomersController.ts b/src/app/api/notary/CustomersController.ts index 0c63db1f..ada54166 100644 --- a/src/app/api/notary/CustomersController.ts +++ b/src/app/api/notary/CustomersController.ts @@ -68,6 +68,8 @@ export default class CustomersController extends ApiController { return; } + if (!customerEntity.contact?.cell_phone_number) return; + const customers = await this.customersService.get({ where: { contact: { email: customerEntity.contact?.email }, diff --git a/src/app/api/super-admin/CustomersController.ts b/src/app/api/super-admin/CustomersController.ts index fdb8ff01..28366c9f 100644 --- a/src/app/api/super-admin/CustomersController.ts +++ b/src/app/api/super-admin/CustomersController.ts @@ -57,7 +57,7 @@ export default class CustomersController extends ApiController { /** * @description Create a new customer */ - @Post("/api/v1/notary/customers", [authHandler, ruleHandler]) + @Post("/api/v1/super-admin/customers", [authHandler, ruleHandler]) protected async post(req: Request, response: Response) { try { //init IUser resource with request body values @@ -70,6 +70,8 @@ export default class CustomersController extends ApiController { return; } + if (!customerEntity.contact?.cell_phone_number) return; + const customers = await this.customersService.get({ where: { contact: { email: customerEntity.contact?.email }, diff --git a/src/app/middlewares/AuthHandler.ts b/src/app/middlewares/AuthHandler.ts index bd3f1293..28c1f082 100644 --- a/src/app/middlewares/AuthHandler.ts +++ b/src/app/middlewares/AuthHandler.ts @@ -13,7 +13,7 @@ export default function authHandler(req: Request, response: Response, next: Next return; } - const authService = Container.get(AuthService); + const authService = Container.get(AuthService); authService.verifyAccessToken(token, (err, userPayload) => { if (err) { response.status(HttpCodes.UNAUTHORIZED).send("Error while verifying token"); From 67dfcaec5f8b98266c4938d3c3c9feb43e86b2cd Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Fri, 15 Dec 2023 16:03:31 +0100 Subject: [PATCH 3/4] :sparkles: Errors in french for front --- .../CustomersService/CustomersService.ts | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/services/customer/CustomersService/CustomersService.ts b/src/services/customer/CustomersService/CustomersService.ts index ce8d6fff..f307e2cc 100644 --- a/src/services/customer/CustomersService/CustomersService.ts +++ b/src/services/customer/CustomersService/CustomersService.ts @@ -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({ @@ -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) { From 12744ea98e5d34e57988bcf2199d39ddf2336db4 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Mon, 18 Dec 2023 11:02:47 +0100 Subject: [PATCH 4/4] :bug: Changing error on code expired --- src/services/customer/CustomersService/CustomersService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/customer/CustomersService/CustomersService.ts b/src/services/customer/CustomersService/CustomersService.ts index f307e2cc..234238c8 100644 --- a/src/services/customer/CustomersService/CustomersService.ts +++ b/src/services/customer/CustomersService/CustomersService.ts @@ -18,7 +18,7 @@ export class SmsNotExpiredError extends Error { export class TotpCodeExpiredError extends Error { constructor() { - super("Code non trouvé ou expiré"); + super("Code non trouvé ou expiré, veuillez raffraîchir la page"); } }