Registration and activation

This commit is contained in:
Torsten Schulz
2024-07-20 20:43:18 +02:00
parent 3880a265eb
commit bbf4a2deb3
51 changed files with 3016 additions and 69 deletions

View File

@@ -0,0 +1,37 @@
import nodemailer from 'nodemailer';
import i18n from '../utils/i18n.js';
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: process.env.SMTP_PORT,
secure: process.env.SMTP_SECURE === 'true',
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASSWORD
}
});
export const sendPasswordResetEmail = async (email, resetLink, language) => {
i18n.setLocale(language);
const mailOptions = {
from: process.env.SMTP_FROM,
to: email,
subject: i18n.__('password_reset_subject'),
text: i18n.__('password_reset_text', { resetLink })
};
await transporter.sendMail(mailOptions);
};
export const sendAccountActivationEmail = async (email, activationLink, username, resetToken, language) => {
i18n.setLocale(language);
const mailOptions = {
from: process.env.SMTP_FROM,
to: email,
subject: i18n.__('account_activation_subject'),
text: i18n.__('account_activation_text', { activationLink, username, resetToken }),
html: i18n.__('account_activation_html', { username, activationLink, resetToken })
};
await transporter.sendMail(mailOptions);
};