mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
Added name from magic link token to member creation
refs https://github.com/TryGhost/members.js/issues/26 - Allows magic link tokens to pass member name on signup - Uses member name from magic link token to assign member name during creation
This commit is contained in:
parent
01de256cc4
commit
d5d2cc5137
@ -96,8 +96,7 @@ module.exports = function MembersApi({
|
||||
|
||||
async function getMemberDataFromMagicLinkToken(token) {
|
||||
const email = await magicLinkService.getUserFromToken(token);
|
||||
const {labels = [], ip} = await magicLinkService.getPayloadFromToken(token);
|
||||
|
||||
const {labels = [], ip, name = ''} = await magicLinkService.getPayloadFromToken(token);
|
||||
if (!email) {
|
||||
return null;
|
||||
}
|
||||
@ -126,7 +125,7 @@ module.exports = function MembersApi({
|
||||
return member;
|
||||
}
|
||||
|
||||
await users.create({email, labels, geolocation});
|
||||
await users.create({name, email, labels, geolocation});
|
||||
return getMemberIdentityData(email);
|
||||
}
|
||||
async function getMemberIdentityData(email){
|
||||
@ -165,9 +164,7 @@ module.exports = function MembersApi({
|
||||
await sendEmailWithMagicLink({email, requestedType: emailType, payload});
|
||||
}
|
||||
} else {
|
||||
if (body.labels) {
|
||||
payload.labels = body.labels;
|
||||
}
|
||||
Object.assign(payload, _.pick(body, ['labels', 'name']));
|
||||
await sendEmailWithMagicLink({email, requestedType: emailType, payload});
|
||||
}
|
||||
res.writeHead(201);
|
||||
|
Loading…
Reference in New Issue
Block a user