Fixed missing subscription data in member update endpoint

closes https://github.com/TryGhost/members.js/issues/94

- The member-api package was recently updated to work directly with models and needs explicit `withRelated` options to attack relations
- Without options, the endpoint was returning the default member data without subscriptions attached, which in Portal showed paid member as free
- Fix updates the middleware for updating member data to correctly pass the relations needed to populate the member
This commit is contained in:
Rish 2020-09-04 17:11:04 +05:30
parent dd6ac57aca
commit 2d2fa1a0ba

View File

@ -71,7 +71,12 @@ const updateMemberData = async function (req, res) {
const data = _.pick(req.body, 'name', 'subscribed');
const member = await membersService.ssr.getMemberDataFromSession(req, res);
if (member) {
const updatedMember = await membersService.api.members.update(data, {id: member.id});
const options = {
id: member.id,
withRelated: ['stripeSubscriptions', 'stripeSubscriptions.customer']
};
const updatedMember = await membersService.api.members.update(data, options);
res.json(formattedMemberResponse(updatedMember.toJSON()));
} else {
res.json(null);