Commit 0a91bc61 authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files

Se creó el servicio para enviar emails de reseteo

parent 1d7214b8
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
import { MailerService } from '@nestjs-modules/mailer';
import { Injectable } from '@nestjs/common';
import { MailConstants } from 'src/constants/mail.constants';
import { text } from 'stream/consumers';

@Injectable()
export class EmailService {
    constructor(
        private readonly mailerService: MailerService,
    ) { }

    async sendResetPasswordEmail(email: string, resetCode: string): Promise<void> {
        const mailOptions = {
            to: email,
            subject: 'Reset your password',
            text: `Your reset code is ${resetCode}`,
        };
        try {
            await this.mailerService.sendMail(mailOptions);
        } catch (error) {
            console.error(error);
            throw new Error('Error sending email');
        }
    }
}