From 0743063c15950c3c207c207d084f59841021f9bd Mon Sep 17 00:00:00 2001 From: Alireza Hassani Date: Mon, 10 Aug 2026 10:08:32 +0330 Subject: [PATCH] Reactivate inactive users on successful OTP login or password reset. OTP already proved phone ownership; treating is_active as a hard block made send-otp succeed while login-otp returned a misleading not-registered error. Co-authored-by: Cursor --- src/auth/auth.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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'); }