✨ Password forgotten working
This commit is contained in:
parent
82d24a71a4
commit
8ef401b4b2
@ -120,10 +120,23 @@ export default class CustomersService extends BaseService {
|
||||
|
||||
// 2: Check in the array of totpCodes if one is still valid
|
||||
const validTotpCode = customerHydrated.totpCodes?.find((totpCode) => {
|
||||
return totpCode.expire_at && totpCode.expire_at.getTime() > now;
|
||||
return totpCode.expire_at && totpCode.expire_at.getTime() > now && totpCode.reason === TotpCodesReasons.RESET_PASSWORD;
|
||||
});
|
||||
if (validTotpCode) throw new SmsNotExpiredError();
|
||||
|
||||
// 3: Archive all active totp codes for this customer
|
||||
const activeTotpCodes = customerHydrated.totpCodes?.filter((totpCode) => {
|
||||
return totpCode.expire_at && totpCode.expire_at.getTime() > now;
|
||||
});
|
||||
|
||||
if (activeTotpCodes) {
|
||||
await Promise.all(
|
||||
activeTotpCodes.map(async (totpCode) => {
|
||||
await this.totpCodesRepository.disable(totpCode);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// 3: Generate a new SMS code
|
||||
const totpPin = this.generateTotp();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user