mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
Fixed magic link type for member email update
no issue - In case of a member updating their email, the `updateEmail` type was overridden with `signup` or `signin` without the force option. The fix forces the correct email type for when member requests to update their email.
This commit is contained in:
parent
06f9eb6dfe
commit
2c2d639838
@ -215,7 +215,7 @@ module.exports = function MembersApi({
|
||||
|
||||
middleware.sendMagicLink.use(body.json(), async function (req, res) {
|
||||
const {email, emailType, oldEmail, requestSrc} = req.body;
|
||||
|
||||
let forceEmailType = false;
|
||||
if (!email) {
|
||||
res.writeHead(400);
|
||||
return res.end('Bad Request.');
|
||||
@ -229,18 +229,18 @@ module.exports = function MembersApi({
|
||||
message: 'This email is already associated with a member'
|
||||
});
|
||||
}
|
||||
forceEmailType = true;
|
||||
}
|
||||
|
||||
if (!allowSelfSignup) {
|
||||
const member = oldEmail ? await users.get({oldEmail}) : await users.get({email});
|
||||
if (member) {
|
||||
const tokenData = _.pick(req.body, ['oldEmail']);
|
||||
const forceEmailType = oldEmail ? true : false;
|
||||
await sendEmailWithMagicLink({email, tokenData, requestedType: emailType, requestSrc, options: {forceEmailType}});
|
||||
}
|
||||
} else {
|
||||
const tokenData = _.pick(req.body, ['labels', 'name', 'oldEmail']);
|
||||
await sendEmailWithMagicLink({email, tokenData, requestedType: emailType, requestSrc});
|
||||
await sendEmailWithMagicLink({email, tokenData, requestedType: emailType, requestSrc, options: { forceEmailType }});
|
||||
}
|
||||
res.writeHead(201);
|
||||
return res.end('Created.');
|
||||
|
Loading…
Reference in New Issue
Block a user