diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index a974b80..9e9586a 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -367,6 +367,8 @@ export class AuthService { await this.prisma.user.update({ where: { id: user.id }, data: { + // OTP proves phone ownership — reactivate accounts left inactive (e.g. unfinished signup). + isActive: true, cellVerifiedAt: user.cellVerifiedAt ?? new Date(), lastLoginAt: new Date(), }, @@ -390,6 +392,7 @@ export class AuthService { where: { id: user.id }, data: { passwordHash, + isActive: true, cellVerifiedAt: user.cellVerifiedAt ?? new Date(), }, }); @@ -399,13 +402,13 @@ export class AuthService { }; } - /** Validates OTP (or skips when SMS is disabled) and returns the active user. */ + /** Validates OTP (or skips when SMS is disabled) and returns the user. */ private async consumeOtp(cellNumber: string, code: string) { const user = await this.prisma.user.findUnique({ where: { cellNumber }, }); - if (!user || !user.isActive) { + if (!user) { throw new UnauthorizedException('Cell number is not registered'); }