From 1208b41b9fb9f92f4e3702cd5f67f939fa119822 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Sun, 6 Oct 2019 17:11:37 +0700 Subject: [PATCH] Added allowSelfSignup options to auth config no-issue This flag is used to allow the sendMagicLink middleware to send an email to members which do not yet exist. When this flag is set to false, the only way to create members, would be via the stripe webook, or via the `create` method exposed on the `members` object --- ghost/members-api/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ghost/members-api/index.js b/ghost/members-api/index.js index f0e3e58dfc..c200bee2cb 100644 --- a/ghost/members-api/index.js +++ b/ghost/members-api/index.js @@ -14,6 +14,7 @@ module.exports = function MembersApi({ publicKey }, auth: { + allowSelfSignup, getSigninURL }, paymentConfig, @@ -131,7 +132,14 @@ module.exports = function MembersApi({ } const emailType = req.body.emailType; try { - await sendEmailWithMagicLink(email, emailType); + if (!allowSelfSignup) { + const member = await users.get({email}); + if (member) { + await sendEmailWithMagicLink(email, emailType); + } + } else { + await sendEmailWithMagicLink(email, emailType); + } res.writeHead(201); return res.end('Created.'); } catch (err) {