Updates to sending user details

This commit is contained in:
2025-08-03 13:26:20 -06:00
parent e488a23bfb
commit 532286217e
22 changed files with 1669 additions and 156 deletions

View File

@@ -92,8 +92,41 @@ const sendPasswordRecovery = async (user) => {
}
};
const sendLoginDetails = async (user) => {
try {
const baseUrl = config.isProduction ?
`https://map.${config.domain}` :
`http://localhost:${config.port}`;
const isAdmin = user.admin || user.Admin || false;
const variables = {
APP_NAME: process.env.APP_NAME || 'CMlite Map',
USER_NAME: user.Name || user.name || user.Email || user.email,
USER_EMAIL: user.Email || user.email,
PASSWORD: user.Password || user.password,
USER_ROLE: isAdmin ? 'Administrator' : 'User',
LOGIN_URL: `${baseUrl}/login.html`,
TIMESTAMP: new Date().toLocaleString()
};
const { html, text } = await emailTemplates.render('login-details', variables);
return await sendEmail({
to: user.Email || user.email,
subject: `Your Login Details - ${variables.APP_NAME}`,
text,
html
});
} catch (error) {
logger.error('Failed to send login details email:', error);
throw error;
}
};
module.exports = {
initializeEmailService,
sendEmail,
sendPasswordRecovery
sendPasswordRecovery,
sendLoginDetails
};