✨ Clearing totp code after login/set password
This commit is contained in:
parent
6c00162544
commit
cdbb3e3257
@ -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()
|
||||
|
@ -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>({
|
||||
...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,
|
||||
},
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user