Skip to content

Commit

Permalink
fix: email otp async behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
harshalranjhani committed Jun 25, 2024
1 parent 79a0cff commit d8280a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class AuthService {
const otp = randomInt(100000, 1000000); // 6 digit otp
const otpId = randomUUID();

this.mailService.sendUsersOtp(email, otp);
await this.mailService.sendUsersOtp(email, otp);

this.cacheManager.set(otpId, { otp, user }, 0); // set for 5 minutes
return { otpId };
Expand Down
4 changes: 3 additions & 1 deletion src/mail/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ export class MailService {
</html>
`;

await this.mailerService.sendMail({
console.log('Sending email to', email);
const info = await this.mailerService.sendMail({
to: email,
subject: 'Your OTP for GooglexYug',
html: htmlContent,
});
console.log('Message sent: %s', info.messageId);
}
}

0 comments on commit d8280a3

Please sign in to comment.