diff --git a/src/common/repositories/CustomersRepository.ts b/src/common/repositories/CustomersRepository.ts index 6ab46516..6844fddb 100644 --- a/src/common/repositories/CustomersRepository.ts +++ b/src/common/repositories/CustomersRepository.ts @@ -5,8 +5,8 @@ import { Customers, ECivility, ECustomerStatus, Prisma } from "@prisma/client"; import { Customer } from "le-coffre-resources/dist/SuperAdmin"; type IExcludedCustomerVars = { - totpCode?: string; - totpCodeExpire?: Date; + totpCode?: string | null; + totpCodeExpire?: Date | null; password?: string; }; @Service() diff --git a/src/services/customer/CustomersService/CustomersService.ts b/src/services/customer/CustomersService/CustomersService.ts index fe52345b..ccab039e 100644 --- a/src/services/customer/CustomersService/CustomersService.ts +++ b/src/services/customer/CustomersService/CustomersService.ts @@ -158,6 +158,16 @@ export default class CustomersService extends BaseService { const isPasswordValid = await this.authService.comparePassword(password, customer.password); if (!isPasswordValid) throw new InvalidPasswordError(); + await this.customerRepository.update( + customer.uid as string, + Customer.hydrate({ + ...customer, + }), + { + totpCode: null, + totpCodeExpire: null, + }, + ); // 6: Return the customer return customer; } @@ -173,6 +183,8 @@ export default class CustomersService extends BaseService { ...customer, }), { + totpCode: null, + totpCodeExpire: null, password, }, );