Skip to content

Commit 7bc9ad2

Browse files
committed
fix(otp): replace LessThanOrEqual with MoreThanOrEqual
1 parent 83729d8 commit 7bc9ad2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

http/auth.http

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ POST {{apiUrl}}/auth/password/reset/email
6767

6868
{
6969
"email": "{{$dotenv REST_USER_LOGIN}}",
70-
"token": "f5792b25-e9ce-44e4-a34d-a9382257b086",
70+
"token": "b70e0419-9839-4a6e-a799-8580e929e5a9",
7171
"password": "{{$dotenv REST_USER_PASSWORD}}"
7272
}

src/modules/otp/service/otp.validator.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { inject as Inject, injectable as Injectable } from 'tsyringe';
2-
import { LessThanOrEqual } from 'typeorm';
2+
import { MoreThanOrEqual } from 'typeorm';
33

4+
import { SortBy } from '@common/enums';
45
import { DateUtil } from '@common/utils';
56
import { ValidatorServiceCore } from '@core/service';
67
import type { FullUser } from '@modules/user';
@@ -27,7 +28,7 @@ export class OtpValidatorService
2728
where: {
2829
...query,
2930
userId: user.id,
30-
expiredAt: LessThanOrEqual(new Date()),
31+
expiredAt: MoreThanOrEqual(new Date()),
3132
isVerified: false,
3233
},
3334
});
@@ -44,8 +45,9 @@ export class OtpValidatorService
4445
where: {
4546
...query,
4647
userId: user.id,
47-
createdAt: LessThanOrEqual(createdAt),
48+
createdAt: MoreThanOrEqual(createdAt),
4849
},
50+
order: { createdAt: SortBy.DESC },
4951
});
5052

5153
if (otp) {
@@ -58,7 +60,7 @@ export class OtpValidatorService
5860
private calculateResendTime(): Date {
5961
return DateUtil.addMillisecondToDate(
6062
new Date(),
61-
DateUtil.parseStringToMs(DELAY_FOR_RESEND),
63+
-DateUtil.parseStringToMs(DELAY_FOR_RESEND),
6264
);
6365
}
6466
}

0 commit comments

Comments
 (0)