Merge pull request #54 from HamzaSha1/fix/verfy-email

Implement OTP generation and email verification logic in UserService
This commit is contained in:
abdalhamid99
2025-10-28 16:17:51 +03:00
committed by GitHub

View File

@ -226,7 +226,15 @@ export class UserService {
if (userWithEmail) { if (userWithEmail) {
if (userWithEmail.id === userId) { 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`); this.logger.error(`Email ${email} is already taken by another user`);