Implement OTP generation and email verification logic in UserService

This commit is contained in:
Abdalhamid Alhamad
2025-10-28 15:52:24 +03:00
parent 39d5fc1869
commit a3a61b4923

View File

@ -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`);