From b852de95c8abe71f6c2b8b6d7f817b169dcbb171 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Tue, 1 Oct 2019 13:55:20 +0700 Subject: [PATCH] Updated members-api to pass the emailType to magic-link no-issue This will allow requests to send the correct email --- ghost/members-api/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ghost/members-api/index.js b/ghost/members-api/index.js index 31d3596b0e..bd563b8f92 100644 --- a/ghost/members-api/index.js +++ b/ghost/members-api/index.js @@ -61,8 +61,8 @@ module.exports = function MembersApi({ getSigninURL }); - async function sendEmailWithMagicLink(email){ - return magicLinkService.sendMagicLink({email, user: {email}}); + async function sendEmailWithMagicLink(email, type){ + return magicLinkService.sendMagicLink({email, user: {email}, type}); } const users = Users({ @@ -108,8 +108,9 @@ module.exports = function MembersApi({ res.writeHead(400); return res.end('Bad Request.'); } + const emailType = req.body.emailType; try { - await sendEmailWithMagicLink(email); + await sendEmailWithMagicLink(email, emailType); res.writeHead(201); return res.end('Created.'); } catch (err) { @@ -171,7 +172,8 @@ module.exports = function MembersApi({ await stripe.addCustomerToMember(member, customer); - await sendEmailWithMagicLink(customer.email); + const emailType = 'signup'; + await sendEmailWithMagicLink(customer.email, emailType); res.writeHead(200); res.end(); } catch (err) {