mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
refacto
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
e000432027
commit
de395dfc88
@ -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']),
|
||||
|
||||
@ -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 });
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user