@@ -15,7 +15,6 @@ import { baseProcedure, createTRPCRouter } from '@/lib/trpc/init';
1515import {
1616 OrganizationIdInputSchema ,
1717 organizationOwnerProcedure ,
18- ensureOrganizationAccess ,
1918 organizationMemberProcedure ,
2019} from '@/routers/organizations/utils' ;
2120import { TRPCError } from '@trpc/server' ;
@@ -117,7 +116,7 @@ export const organizationsSubscriptionRouter = createTRPCRouter({
117116 return { status : paymentStatus } ;
118117 } ) ,
119118
120- getSubscriptionStripeUrl : baseProcedure
119+ getSubscriptionStripeUrl : organizationOwnerProcedure
121120 . input ( SubscriptionRequestSchema )
122121 . mutation ( async ( { input, ctx } ) => {
123122 const { user } = ctx ;
@@ -132,20 +131,13 @@ export const organizationsSubscriptionRouter = createTRPCRouter({
132131 const customerId = await getOrCreateStripeCustomerIdForOrganization ( org . id ) ;
133132 const subscriptions = await getSubscriptionsForStripeCustomerId ( customerId ) ;
134133
135- // if any subscriptions are not ended, throw bad request error
136134 if ( subscriptions . find ( sub => sub . ended_at == null ) ) {
137135 throw new TRPCError ( {
138136 code : 'BAD_REQUEST' ,
139137 message : 'Organization has active subscription(s)' ,
140138 } ) ;
141139 }
142140
143- // if any subscriptions exist we need to enforce security
144- // otherwise, we can't enforce ownership as the org is still not finished being set up
145- if ( subscriptions . length ) {
146- await ensureOrganizationAccess ( ctx , organizationId , [ 'owner' , 'billing_manager' ] ) ;
147- }
148-
149141 const result = await getStripeSeatsCheckoutUrl ( {
150142 kiloUserId : user . id ,
151143 stripeCustomerId : customerId ,
0 commit comments