🐛 Fixed incorrect payload creation for magic link token

no issue

- The extra payload added to magic link token included `name`, `labels` and `oldEmail`
- Refactor in commit [here](bf63ffe424 (diff-9f9ef757543bb9a90baba0d3bea76a83L157-R169)) changed the `body` variable assignment causing the payload objection creation to not include the extra data from request body
- Updates `body` to `req.body` to use correct data from request
This commit is contained in:
Rish 2020-07-08 21:48:12 +05:30
parent 5b909735fd
commit 1acf7d40be

View File

@ -202,14 +202,17 @@ module.exports = function MembersApi({
});
}
}
let extraPayload = {};
if (!allowSelfSignup) {
const member = await users.get({email});
if (member) {
Object.assign(payload, _.pick(body, ['oldEmail']));
extraPayload = _.pick(req.body, ['oldEmail']);
Object.assign(payload, extraPayload);
await sendEmailWithMagicLink({email, requestedType: emailType, payload});
}
} else {
Object.assign(payload, _.pick(body, ['labels', 'name', 'oldEmail']));
extraPayload = _.pick(req.body, ['labels', 'name', 'oldEmail']);
Object.assign(payload, extraPayload);
await sendEmailWithMagicLink({email, requestedType: emailType, payload});
}
res.writeHead(201);