From 631e78631f7121c9ccfe6d20694f5c650e4851a3 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Thu, 1 Jul 2021 20:19:56 +0100 Subject: [PATCH] Updated linkSubscription to handle comped status refs https://github.com/TryGhost/Team/issues/790 When linking a subscription to a member we must also update their status. We could be in one of many states, so we start with the initial values of either 'free' or 'comped' based on whether the member has any products. We then make sure to updated the status to 'paid' if we find any active subscriptions associated with the member, otherwise we leave it as the initial value. --- ghost/members-api/lib/repositories/member/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghost/members-api/lib/repositories/member/index.js b/ghost/members-api/lib/repositories/member/index.js index 3a2d4257e6..986daf69cc 100644 --- a/ghost/members-api/lib/repositories/member/index.js +++ b/ghost/members-api/lib/repositories/member/index.js @@ -441,8 +441,8 @@ module.exports = class MemberRepository { }, options); } - let status = 'free'; let memberProducts = (await member.related('products').fetch(options)).toJSON(); + let status = memberProducts.length === 0 ? 'free' : 'comped'; if (this.isActiveSubscriptionStatus(subscription.status)) { status = 'paid'; if (ghostProduct) {