From a3a61b49231c60f35099d5fb2093f215f5c41a49 Mon Sep 17 00:00:00 2001 From: Abdalhamid Alhamad Date: Tue, 28 Oct 2025 15:52:24 +0300 Subject: [PATCH] Implement OTP generation and email verification logic in UserService --- src/user/services/user.service.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/user/services/user.service.ts b/src/user/services/user.service.ts index 188accb..73e2e58 100644 --- a/src/user/services/user.service.ts +++ b/src/user/services/user.service.ts @@ -226,7 +226,15 @@ export class UserService { if (userWithEmail) { if (userWithEmail.id === userId) { - return; + this.logger.log(`Generating OTP for current email ${email} for user ${userId}`); + await this.userRepository.update(userId, { isEmailVerified: false }); + + return this.otpService.generateAndSendOtp({ + userId, + recipient: email, + otpType: OtpType.EMAIL, + scope: OtpScope.VERIFY_EMAIL, + }); } this.logger.error(`Email ${email} is already taken by another user`);