fix: fix otp security issue and race condition

This commit is contained in:
2026-11-06 19:00:37 +03:30
parent 2051090d3d
commit 48e9ab5531
5 changed files with 156 additions and 17 deletions
+3
View File
@@ -38,6 +38,9 @@ export class OTP extends BaseEntity {
@Column({ type: 'boolean', default: false })
used!: boolean;
@Column({ type: 'integer', default: 0 })
failedAttempts!: number;
@BeforeInsert()
setExpiry() {
this.expiresAt = new Date(Date.now() + 2 * 60 * 1000);