mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Added flag to create member for sending email
no-issue This allows us to give more functionality to consumers, with a smaller API (rather than exposing the methods for sending a magic-link email)
This commit is contained in:
parent
ff0dc6a168
commit
530390124b
@ -54,15 +54,6 @@ module.exports = function MembersApi({
|
||||
}
|
||||
}
|
||||
|
||||
let users = Users({
|
||||
stripe,
|
||||
createMember,
|
||||
getMember,
|
||||
updateMember,
|
||||
deleteMember,
|
||||
listMembers
|
||||
});
|
||||
|
||||
const magicLinkService = new MagicLink({
|
||||
transporter,
|
||||
publicKey,
|
||||
@ -73,6 +64,17 @@ module.exports = function MembersApi({
|
||||
async function sendEmailWithMagicLink(email){
|
||||
return magicLinkService.sendMagicLink({email, user: {email}});
|
||||
}
|
||||
|
||||
const users = Users({
|
||||
sendEmailWithMagicLink,
|
||||
stripe,
|
||||
createMember,
|
||||
getMember,
|
||||
updateMember,
|
||||
deleteMember,
|
||||
listMembers
|
||||
});
|
||||
|
||||
async function getMemberDataFromMagicLinkToken(token){
|
||||
const user = await magicLinkService.getUserFromToken(token);
|
||||
const email = user && user.email;
|
||||
|
@ -1,4 +1,5 @@
|
||||
module.exports = function ({
|
||||
sendEmailWithMagicLink,
|
||||
stripe,
|
||||
createMember,
|
||||
getMember,
|
||||
@ -53,7 +54,11 @@ module.exports = function ({
|
||||
}
|
||||
|
||||
async function create(data, options) {
|
||||
return createMember(data, options);
|
||||
const member = await createMember(data);
|
||||
if (options.sendEmail) {
|
||||
await sendEmailWithMagicLink(member.email, options.emailType);
|
||||
}
|
||||
return member;
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user