Skip to content

Commit 4240b1c

Browse files
committed
fix(enterprise): use isOrganizationOnEnterprisePlan for org-scoped enterprise check
1 parent 59870ac commit 4240b1c

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

  • apps/sim/app/api/organizations/[id]/whitelabel

apps/sim/app/api/organizations/[id]/whitelabel/route.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { db } from '@sim/db'
2-
import { member, organization, subscription } from '@sim/db/schema'
2+
import { member, organization } from '@sim/db/schema'
33
import { createLogger } from '@sim/logger'
4-
import { and, eq, inArray } from 'drizzle-orm'
4+
import { and, eq } from 'drizzle-orm'
55
import { type NextRequest, NextResponse } from 'next/server'
66
import { z } from 'zod'
77
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
88
import { getSession } from '@/lib/auth'
9-
import { checkEnterprisePlan, USABLE_SUBSCRIPTION_STATUSES } from '@/lib/billing/core/subscription'
9+
import { isOrganizationOnEnterprisePlan } from '@/lib/billing/core/subscription'
1010
import type { OrganizationWhitelabelSettings } from '@/lib/branding/types'
1111

1212
const logger = createLogger('WhitelabelAPI')
@@ -140,18 +140,9 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
140140
)
141141
}
142142

143-
const [orgSubscription] = await db
144-
.select()
145-
.from(subscription)
146-
.where(
147-
and(
148-
eq(subscription.referenceId, organizationId),
149-
inArray(subscription.status, USABLE_SUBSCRIPTION_STATUSES)
150-
)
151-
)
152-
.limit(1)
143+
const hasEnterprisePlan = await isOrganizationOnEnterprisePlan(organizationId)
153144

154-
if (!orgSubscription || !checkEnterprisePlan(orgSubscription)) {
145+
if (!hasEnterprisePlan) {
155146
return NextResponse.json(
156147
{ error: 'Whitelabeling is available on Enterprise plans only' },
157148
{ status: 403 }

0 commit comments

Comments
 (0)