- Add forgot-password and reset-password pages and API routes - Add email verification with token generation on registration - Add resend-verification endpoint with 60s rate limit - Add shared email utility (nodemailer, Migadu SMTP) - Add VerificationBanner in dashboard layout - Add PasswordResetToken and EmailVerificationToken models - Add emailVerified field to User model - Extend NextAuth session with isEmailVerified - Add forgot-password link to login page - Wire EMAIL_PASSWORD env var in docker-compose
37 lines
683 B
TypeScript
37 lines
683 B
TypeScript
import nodemailer from "nodemailer";
|
|
|
|
interface SendEmailOptions {
|
|
to: string;
|
|
subject: string;
|
|
html: string;
|
|
}
|
|
|
|
export async function sendEmail({ to, subject, html }: SendEmailOptions) {
|
|
const password = process.env.EMAIL_PASSWORD;
|
|
|
|
if (!password) {
|
|
console.warn(
|
|
"[email] EMAIL_PASSWORD not set — skipping email send to:",
|
|
to
|
|
);
|
|
return;
|
|
}
|
|
|
|
const transporter = nodemailer.createTransport({
|
|
host: "smtp.migadu.com",
|
|
port: 465,
|
|
secure: true,
|
|
auth: {
|
|
user: "hunter@repi.fun",
|
|
pass: password,
|
|
},
|
|
});
|
|
|
|
await transporter.sendMail({
|
|
from: "AgentLens <hunter@repi.fun>",
|
|
to,
|
|
subject,
|
|
html,
|
|
});
|
|
}
|