Skip to content

Commit

Permalink
Fix - pass all the required parameters to email template
Browse files Browse the repository at this point in the history
  • Loading branch information
Ugo committed Jun 10, 2019
1 parent b89adb5 commit 68c18c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions server/auth/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ exports.postForgot = (req, res) => {
});
})
.catch(err => {
console.log(err);
res
.status(err.status || 500)
.send({ message: err.message || 'An error occurred', err });
Expand Down
11 changes: 7 additions & 4 deletions server/email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const ejs = require('ejs');
const cfg = require('../../cfg');
const getTransporter = require('./get-transporter');

const HOST = cfg.clientHost;

const sendEmail = props => {
const { email, token, template } = props;
const host = cfg.clientHost;

// Sets the service used
const transporter = new Promise((resolve, reject) => {
Expand All @@ -17,7 +18,7 @@ const sendEmail = props => {
loadTemplate({
to: email,
token,
host,
host: HOST,
type: template
}),
transporter
Expand All @@ -32,7 +33,7 @@ const sendEmail = props => {
const loadTemplate = props => {
const { to, token, host, type } = props;
const year = new Date().getFullYear();
const { html, subject, text } = getTemplate(type);
const { html, subject, text } = getTemplate({ type, host, token });
return ejs.renderFile(html, { token, host, year }).then(html => {
return {
from: '"Gastronomycon" <noreply@gastronomycon.matchyourtie.com>',
Expand All @@ -45,7 +46,9 @@ const loadTemplate = props => {
};

// util for selecting the specific template
const getTemplate = type => {
const getTemplate = props => {
const { type, host, token } = props;

if (type == 'activation') {
return {
html: `${__dirname}/template/activate-account.ejs`,
Expand Down

0 comments on commit 68c18c7

Please sign in to comment.