mirror of
https://github.com/andwati/nestjs-auth-email-phone.git
synced 2026-11-28 13:38:47 +00:00
feat: Implement OTP-based authentication with Redis, SMS, and email services, including new controllers and providers.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// mail.service.ts
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import * as nodemailer from 'nodemailer';
|
||||
|
||||
@Injectable()
|
||||
export class MailService {
|
||||
private transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST,
|
||||
port: Number(process.env.SMTP_PORT),
|
||||
secure: true,
|
||||
auth: {
|
||||
user: process.env.SMTP_USER,
|
||||
pass: process.env.SMTP_PASS
|
||||
}
|
||||
});
|
||||
|
||||
async sendOtp(email: string, otp: string) {
|
||||
await this.transporter.sendMail({
|
||||
from: '"Your App" <[email protected]>',
|
||||
to: email,
|
||||
subject: 'Your OTP Code',
|
||||
text: `Your verification code is ${otp}. It expires in 5 minutes.`
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user