Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
Pierre Noël 2020-06-29 14:36:52 +02:00 committed by Alexandre Bodin
parent e000432027
commit de395dfc88
2 changed files with 10 additions and 9 deletions

View File

@ -68,10 +68,10 @@ const forgotPassword = async ({ email } = {}) => {
.sendTemplatedEmail(
{
to: user.email,
from: strapi.config.get('server.admin.forgotPassword', {}).from,
replyTo: strapi.config.get('server.admin.forgotPassword', {}).replyTo,
from: strapi.config.get('server.admin.forgotPassword.from'),
replyTo: strapi.config.get('server.admin.forgotPassword.replyTo'),
},
strapi.config.get('server.admin.forgotPassword', {}).emailTemplate,
strapi.config.get('server.admin.forgotPassword.emailTemplate'),
{
url,
user: _.pick(user, ['email', 'firstname', 'lastname', 'username']),

View File

@ -26,12 +26,13 @@ const sendTemplatedEmail = (emailOptions = {}, emailTemplate = {}, data = {}) =>
);
}
const templatedAttributes = {};
for (let attribute of attributes) {
if (emailTemplate[attribute]) {
templatedAttributes[attribute] = _.template(emailTemplate[attribute])(data);
}
}
const templatedAttributes = attributes.reduce(
(compiled, attribute) =>
emailTemplate[attribute]
? Object.assign(compiled, { [attribute]: _.template(emailTemplate[attribute])(data) })
: compiled,
{}
);
return strapi.plugins.email.provider.send({ ...emailOptions, ...templatedAttributes });
};