Skip to content

Commit

Permalink
fix(server): ignore invalid subscription variant (#8892)
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo authored Nov 22, 2024
1 parent cd30e1a commit b5fed7b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/backend/server/src/plugins/payment/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class UserSubscriptionResolver {
};
}

return this.db.userSubscription.findUnique({
const subscription = await this.db.userSubscription.findUnique({
where: {
userId_plan: {
userId: user.id,
Expand All @@ -379,6 +379,18 @@ export class UserSubscriptionResolver {
status: SubscriptionStatus.Active,
},
});

if (
subscription &&
subscription.variant &&
![SubscriptionVariant.EA, SubscriptionVariant.Onetime].includes(
subscription.variant as SubscriptionVariant
)
) {
subscription.variant = null;
}

return subscription;
}

@ResolveField(() => [UserSubscriptionType])
Expand Down

0 comments on commit b5fed7b

Please sign in to comment.