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

This commit is contained in:
liuyi 2023-11-03 12:00:58 +08:00 committed by GitHub
parent fb0aaabe53
commit f6cfe7c8a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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