Skip to content

Commit

Permalink
Merge def41aa into 31358dc
Browse files Browse the repository at this point in the history
  • Loading branch information
frensing committed Nov 24, 2021
2 parents 31358dc + def41aa commit 871de28
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 49 deletions.
3 changes: 2 additions & 1 deletion controllers/web/list_users.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ exports.create = function (req, res) {
};

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('user_info', '', user.email, mail_data, translation);
email.send('user_info', '', user.email, mail_data, translation, lang);
}

res.send({
Expand Down
9 changes: 6 additions & 3 deletions controllers/web/notifies.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ function send_message_all_users(req, res, errors) {
const emails = users.map((elem) => elem.email).join();

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('', req.body.subject, emails, req.body.body, translation);
email.send('', req.body.subject, emails, req.body.body, translation, lang);

req.session.message = {
text: ' Success sending email.',
Expand Down Expand Up @@ -117,9 +118,10 @@ function send_message_organization(req, res, errors) {
const emails = users.map((elem) => elem.email).join();

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('', req.body.subject, emails, req.body.body, translation);
email.send('', req.body.subject, emails, req.body.body, translation, lang);

req.session.message = {
text: ' Success sending email.',
Expand Down Expand Up @@ -183,9 +185,10 @@ function send_message_users_by_id(req, res, errors) {
const emails = result.users.map((elem) => elem.email).join();

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('', req.body.subject, emails, req.body.body, translation);
email.send('', req.body.subject, emails, req.body.body, translation, lang);

req.session.message = {
text: ' Success sending email.',
Expand Down
3 changes: 2 additions & 1 deletion controllers/web/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ exports.avoid_2fa_email = function (req, res) {
};

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('disable_2fa', '', user.email, mail_data, translation);
email.send('disable_2fa', '', user.email, mail_data, translation, lang);

req.session.message = {
text: 'Send instructions email to ' + user.email,
Expand Down
3 changes: 2 additions & 1 deletion controllers/web/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ exports.email = function (req, res) {
};

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('change_email', '', req.body.email, mail_data, translation);
email.send('change_email', '', req.body.email, mail_data, translation, lang);

res.locals.message = {
text: `An emails has been sent to verify your account.
Expand Down
9 changes: 6 additions & 3 deletions controllers/web/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,10 @@ exports.create = function (req, res) {
};

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('activate', '', user.email, mail_data, translation);
email.send('activate', '', user.email, mail_data, translation, lang);

res.locals.message = {
text: 'Account created succesfully, check your email for the confirmation link.',
Expand Down Expand Up @@ -831,8 +832,9 @@ exports.password_send_email = function (req, res) {
};

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;
// Send an email message to the user
email.send('forgot_password', '', user.email, mail_data, translation);
email.send('forgot_password', '', user.email, mail_data, translation, lang);

req.session.message = {
text: 'Reset password instructions send to ' + user.email,
Expand Down Expand Up @@ -1006,9 +1008,10 @@ exports.resend_confirmation = function (req, res) {
};

const translation = req.app.locals.translation;
const lang = req.app.locals.lang;

// Send an email message to the user
email.send('activate', '', user.email, mail_data, translation);
email.send('activate', '', user.email, mail_data, translation, lang);

req.session.message = {
text: 'Resend confirmation instructions email to ' + user.email,
Expand Down
10 changes: 8 additions & 2 deletions lib/email.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
const config_service = require('../lib/configService.js');
const config = config_service.get_config();
const mailer = require('../lib/mailer').mailer();
const path = require('path');
const debug = require('debug')('idm:email');
const ejs = require('ejs');
const fs = require('fs');

// Function te fill message template and send this to specific users
exports.send = function (view, subject, emails, message, translation) {
exports.send = function (view, subject, emails, message, translation, lang) {
debug(' --> send_email');

// Merge all objects needed to fill the email template
const render = {
...{ view },
...{ translation },
...{ data: message }
...{ data: message },
...{ config },
...{ fs },
...{ lang }
};

// If there is no view specified it means that is a custom email from admin/notifies view
Expand Down
5 changes: 5 additions & 0 deletions views/templates/email/_footer.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
2018 ©
<a style="color: #193B6B; text-decoration: none;" href="https://github.com/ging"
onMouseOver="this.style.cssText= 'color: #48B9C9; text-decoration: none;'"
onMouseOut="this.style.cssText= 'color: #193B6B; text-decoration: none;'">GING DIT</a>-
<%=translation.templates.email.base_email.content01%>
2 changes: 2 additions & 0 deletions views/templates/email/_header.ejs

Large diffs are not rendered by default.

109 changes: 71 additions & 38 deletions views/templates/email/base_email.ejs

Large diffs are not rendered by default.

0 comments on commit 871de28

Please sign in to comment.