-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix - pass all the required parameters to email template
- Loading branch information
Ugo
committed
Jun 10, 2019
1 parent
b89adb5
commit 68c18c7
Showing
2 changed files
with
8 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) => { | ||
|
@@ -17,7 +18,7 @@ const sendEmail = props => { | |
loadTemplate({ | ||
to: email, | ||
token, | ||
host, | ||
host: HOST, | ||
type: template | ||
}), | ||
transporter | ||
|
@@ -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" <[email protected]>', | ||
|
@@ -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`, | ||
|