From f6cfe7c8a1b327b4b9f1583de98b56e9875bde4a Mon Sep 17 00:00:00 2001 From: liuyi Date: Fri, 3 Nov 2023 12:00:58 +0800 Subject: [PATCH] fix(server): only treat active subscription as existing (#4826) --- packages/backend/server/src/modules/payment/service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend/server/src/modules/payment/service.ts b/packages/backend/server/src/modules/payment/service.ts index c6d266fd52..6dfbf19218 100644 --- a/packages/backend/server/src/modules/payment/service.ts +++ b/packages/backend/server/src/modules/payment/service.ts @@ -112,13 +112,14 @@ export class SubscriptionService { redirectUrl: string; idempotencyKey: string; }) { - const currentSubscription = await this.db.userSubscription.findUnique({ + const currentSubscription = await this.db.userSubscription.findFirst({ where: { userId: user.id, + status: SubscriptionStatus.Active, }, }); - if (currentSubscription && currentSubscription.end < new Date()) { + if (currentSubscription) { throw new Error('You already have a subscription'); }