From 2d2fa1a0bae4129c72755810fb96be2d3feba508 Mon Sep 17 00:00:00 2001 From: Rish Date: Fri, 4 Sep 2020 17:11:04 +0530 Subject: [PATCH] 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 --- core/server/services/members/middleware.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/server/services/members/middleware.js b/core/server/services/members/middleware.js index 9a8331634a..e9e9805175 100644 --- a/core/server/services/members/middleware.js +++ b/core/server/services/members/middleware.js @@ -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);