Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(server): only treat active subscription as existing (#4826)

liuyif6cfe7c8a1b3
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');
}