mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
Merge pull request #54 from HamzaSha1/fix/verfy-email
Implement OTP generation and email verification logic in UserService
This commit is contained in:
@ -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`);
|
||||||
|
|||||||
Reference in New Issue
Block a user