mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 21:35:19 +00:00
fix: ai balance for unlimited plan
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import config from "@/lib/config"
|
||||
import { getSelfHostedUser, getUserByEmail, getUserById } from "@/models/users"
|
||||
import { getSelfHostedUser, getUserByEmail, getUserById, SELF_HOSTED_USER } from "@/models/users"
|
||||
import { User } from "@prisma/client"
|
||||
import { betterAuth } from "better-auth"
|
||||
import { prismaAdapter } from "better-auth/adapters/prisma"
|
||||
@@ -101,3 +101,10 @@ export function isSubscriptionExpired(user: User) {
|
||||
}
|
||||
return user.membershipExpiresAt && user.membershipExpiresAt < new Date()
|
||||
}
|
||||
|
||||
export function isAiBalanceExhausted(user: User) {
|
||||
if (config.selfHosted.isEnabled || user.membershipPlan === SELF_HOSTED_USER.membershipPlan) {
|
||||
return false
|
||||
}
|
||||
return user.aiBalance <= 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user