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
This commit is contained in:
Fabien O'Carroll 2019-10-06 17:11:37 +07:00
parent a643b3ff1f
commit 1208b41b9f

View File

@ -14,6 +14,7 @@ module.exports = function MembersApi({
publicKey publicKey
}, },
auth: { auth: {
allowSelfSignup,
getSigninURL getSigninURL
}, },
paymentConfig, paymentConfig,
@ -131,7 +132,14 @@ module.exports = function MembersApi({
} }
const emailType = req.body.emailType; const emailType = req.body.emailType;
try { try {
if (!allowSelfSignup) {
const member = await users.get({email});
if (member) {
await sendEmailWithMagicLink(email, emailType); await sendEmailWithMagicLink(email, emailType);
}
} else {
await sendEmailWithMagicLink(email, emailType);
}
res.writeHead(201); res.writeHead(201);
return res.end('Created.'); return res.end('Created.');
} catch (err) { } catch (err) {