correction responsive
This commit is contained in:
@@ -75,7 +75,7 @@ export async function scheduleUserDeletion(userId: string, reason: string, delay
|
|||||||
|
|
||||||
// Send notification email
|
// Send notification email
|
||||||
if (settings?.deleteAccountTemplate) {
|
if (settings?.deleteAccountTemplate) {
|
||||||
const { sendEmail } = await import("@/../../lib/mail");
|
const { sendEmail } = await import("@/lib/mail");
|
||||||
const html = settings.deleteAccountTemplate
|
const html = settings.deleteAccountTemplate
|
||||||
.replace(/{name}/g, user.name)
|
.replace(/{name}/g, user.name)
|
||||||
.replace(/{siteName}/g, settings.siteName)
|
.replace(/{siteName}/g, settings.siteName)
|
||||||
@@ -114,7 +114,7 @@ export async function reactivateUser(userId: string, reason: string) {
|
|||||||
|
|
||||||
// Send confirmation email
|
// Send confirmation email
|
||||||
if (settings?.reactivateAccountTemplate) {
|
if (settings?.reactivateAccountTemplate) {
|
||||||
const { sendEmail } = await import("@/../../lib/mail");
|
const { sendEmail } = await import("@/lib/mail");
|
||||||
const html = settings.reactivateAccountTemplate
|
const html = settings.reactivateAccountTemplate
|
||||||
.replace(/{name}/g, user.name)
|
.replace(/{name}/g, user.name)
|
||||||
.replace(/{siteName}/g, settings.siteName)
|
.replace(/{siteName}/g, settings.siteName)
|
||||||
|
|||||||
38
admin/src/lib/mail.ts
Normal file
38
admin/src/lib/mail.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import nodemailer from 'nodemailer';
|
||||||
|
|
||||||
|
console.log('SMTP Config:', {
|
||||||
|
host: process.env.SMTP_HOST,
|
||||||
|
port: process.env.SMTP_PORT,
|
||||||
|
secure: process.env.SMTP_SECURE,
|
||||||
|
user: process.env.SMTP_USER
|
||||||
|
});
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: process.env.SMTP_HOST,
|
||||||
|
port: parseInt(process.env.SMTP_PORT || '587'),
|
||||||
|
secure: process.env.SMTP_SECURE === 'true',
|
||||||
|
auth: {
|
||||||
|
user: process.env.SMTP_USER,
|
||||||
|
pass: process.env.SMTP_PASS,
|
||||||
|
},
|
||||||
|
tls: {
|
||||||
|
rejectUnauthorized: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const sendEmail = async ({ to, subject, html }: { to: string; subject: string; html: string }) => {
|
||||||
|
const mailOptions = {
|
||||||
|
from: process.env.SMTP_FROM || '"Afrohub" <noreply@afrohub.com>',
|
||||||
|
to,
|
||||||
|
subject,
|
||||||
|
html,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const info = await transporter.sendMail(mailOptions);
|
||||||
|
console.log('Email sent: ' + info.response);
|
||||||
|
return info;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error sending email:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -30,7 +30,7 @@ export async function reactivateUserAccount(userId: string, reason: string) {
|
|||||||
// Optionnel : Envoyer un mail de confirmation
|
// Optionnel : Envoyer un mail de confirmation
|
||||||
const settings = await prisma.siteSetting.findUnique({ where: { id: "singleton" } });
|
const settings = await prisma.siteSetting.findUnique({ where: { id: "singleton" } });
|
||||||
if (settings?.reactivateAccountTemplate) {
|
if (settings?.reactivateAccountTemplate) {
|
||||||
const { sendEmail } = await import("@/../lib/mail");
|
const { sendEmail } = await import("@/lib/mail");
|
||||||
const html = settings.reactivateAccountTemplate
|
const html = settings.reactivateAccountTemplate
|
||||||
.replace(/{name}/g, user.name)
|
.replace(/{name}/g, user.name)
|
||||||
.replace(/{siteName}/g, settings.siteName)
|
.replace(/{siteName}/g, settings.siteName)
|
||||||
|
|||||||
2
next-env.d.ts
vendored
2
next-env.d.ts
vendored
@@ -1,6 +1,6 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
import "./.next/dev/types/routes.d.ts";
|
import "./.next/types/routes.d.ts";
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||||
|
|||||||
Reference in New Issue
Block a user