MCPcopy Index your code
hub / github.com/simstudioai/sim / authorizeSubscriptionReference

Function authorizeSubscriptionReference

apps/sim/lib/billing/authorization.ts:20–38  ·  view source on GitHub ↗
(
  userId: string,
  referenceId: string,
  action?: string
)

Source from the content-addressed store, hash-verified

18 * - Personal subscriptions skip this check to allow upgrades.
19 */
20export async function authorizeSubscriptionReference(
21 userId: string,
22 referenceId: string,
23 action?: string
24): Promise<boolean> {
25 if (!isOrgScopedSubscription({ referenceId }, userId)) {
26 return true
27 }
28
29 if (action === 'upgrade-subscription' && (await hasPaidSubscription(referenceId))) {
30 logger.warn('Blocking checkout - active subscription already exists for organization', {
31 userId,
32 referenceId,
33 })
34 return false
35 }
36
37 return isOrganizationOwnerOrAdmin(userId, referenceId)
38}

Callers 1

auth.tsFile · 0.90

Calls 4

isOrgScopedSubscriptionFunction · 0.90
hasPaidSubscriptionFunction · 0.90
warnMethod · 0.65

Tested by

no test coverage detected