Skip to content

Commit 62727f0

Browse files
committed
harden further
1 parent 2bb951d commit 62727f0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

apps/sim/lib/billing/client/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export interface SubscriptionData {
2525
isPro: boolean
2626
isTeam: boolean
2727
isEnterprise: boolean
28+
/** True when the subscription's `referenceId` is an organization. */
29+
isOrgScoped: boolean
30+
organizationId: string | null
2831
plan: string
2932
status: string | null
3033
seats: number | null
@@ -59,6 +62,8 @@ export interface SubscriptionStore {
5962
isPro: boolean
6063
isTeam: boolean
6164
isEnterprise: boolean
65+
isOrgScoped: boolean
66+
organizationId: string | null
6267
isFree: boolean
6368
plan: string
6469
status: string | null

apps/sim/lib/billing/client/utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export function getSubscriptionStatus(
3131
isPro: subscriptionData?.isPro ?? false,
3232
isTeam: subscriptionData?.isTeam ?? false,
3333
isEnterprise: subscriptionData?.isEnterprise ?? false,
34+
isOrgScoped: subscriptionData?.isOrgScoped ?? false,
35+
organizationId: subscriptionData?.organizationId ?? null,
3436
isFree: !(subscriptionData?.isPaid ?? false),
3537
plan: subscriptionData?.plan ?? 'free',
3638
status: subscriptionData?.status ?? null,
@@ -45,7 +47,12 @@ export function getSubscriptionAccessState(
4547
const status = getSubscriptionStatus(subscriptionData)
4648
const billingBlocked = Boolean(subscriptionData?.billingBlocked)
4749
const hasUsablePaidAccess = hasUsableSubscriptionAccess(status.status, billingBlocked)
48-
const hasUsableTeamAccess = hasUsablePaidAccess && (status.isTeam || status.isEnterprise)
50+
// Team-management features (invitations, seats, roles) are available on
51+
// any paid subscription attached to an organization — including `pro_*`
52+
// plans that have been transferred to an org. Plan-name gating would
53+
// miss those.
54+
const hasUsableTeamAccess =
55+
hasUsablePaidAccess && (status.isOrgScoped || status.isTeam || status.isEnterprise)
4956
const hasUsableEnterpriseAccess = hasUsablePaidAccess && status.isEnterprise
5057
const hasUsableMaxAccess =
5158
hasUsablePaidAccess && (getPlanTierCredits(status.plan) >= 25000 || isEnterprise(status.plan))

0 commit comments

Comments
 (0)