✨ 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";
|
import { Customer } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
type IExcludedCustomerVars = {
|
type IExcludedCustomerVars = {
|
||||||
totpCode?: string;
|
totpCode?: string | null;
|
||||||
totpCodeExpire?: Date;
|
totpCodeExpire?: Date | null;
|
||||||
password?: string;
|
password?: string;
|
||||||
};
|
};
|
||||||
@Service()
|
@Service()
|
||||||
|
@ -158,6 +158,16 @@ export default class CustomersService extends BaseService {
|
|||||||
const isPasswordValid = await this.authService.comparePassword(password, customer.password);
|
const isPasswordValid = await this.authService.comparePassword(password, customer.password);
|
||||||
if (!isPasswordValid) throw new InvalidPasswordError();
|
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
|
// 6: Return the customer
|
||||||
return customer;
|
return customer;
|
||||||
}
|
}
|
||||||
@ -173,6 +183,8 @@ export default class CustomersService extends BaseService {
|
|||||||
...customer,
|
...customer,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
totpCode: null,
|
||||||
|
totpCodeExpire: null,
|
||||||
password,
|
password,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user