File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' hive ' : patch
3+ ---
4+
5+ Fix default organization resolution and prevent missing permissions error.
Original file line number Diff line number Diff line change @@ -78,6 +78,22 @@ export class OrganizationManager {
7878 return this . storage . getOrganization ( selector ) ;
7979 }
8080
81+ async getOrganizationOrNull ( organizationId : string ) {
82+ const canAccessOrganization = await this . session . canPerformAction ( {
83+ action : 'organization:describe' ,
84+ organizationId,
85+ params : {
86+ organizationId,
87+ } ,
88+ } ) ;
89+
90+ if ( canAccessOrganization === false ) {
91+ return null ;
92+ }
93+
94+ return this . storage . getOrganization ( { organizationId } ) ;
95+ }
96+
8197 async getOrganizationBySlug ( organizationSlug : string ) : Promise < Organization | null > {
8298 const organization = await this . storage . getOrganizationBySlug ( { slug : organizationSlug } ) ;
8399
Original file line number Diff line number Diff line change @@ -41,16 +41,14 @@ export const myDefaultOrganization: NonNullable<QueryResolvers['myDefaultOrganiz
4141 } ) ;
4242
4343 if ( orgId ) {
44- const org = await organizationManager . getOrganization ( {
45- organizationId : orgId ,
46- } ) ;
44+ const organization = await organizationManager . getOrganizationOrNull ( orgId ) ;
4745
48- if ( org ) {
46+ if ( organization ) {
4947 return {
5048 selector : {
51- organizationSlug : org . slug ,
49+ organizationSlug : organization . slug ,
5250 } ,
53- organization : org ,
51+ organization,
5452 } ;
5553 }
5654 }
Original file line number Diff line number Diff line change @@ -92,7 +92,6 @@ export interface Storage {
9292 installationId : string ;
9393 } ) : Promise < Organization | null > ;
9494 getOrganization ( _ : { organizationId : string } ) : Promise < Organization | never > ;
95- getMyOrganization ( _ : { userId : string } ) : Promise < Organization | null > ;
9695 getOrganizations ( _ : { userId : string } ) : Promise < readonly Organization [ ] | never > ;
9796 createOrganization (
9897 _ : Pick < Organization , 'slug' > & {
Original file line number Diff line number Diff line change @@ -1335,13 +1335,6 @@ export async function createStorage(
13351335 ) ,
13361336 ) ;
13371337 } ,
1338- async getMyOrganization ( { userId : user } ) {
1339- const org = await pool . maybeOne < Slonik < organizations > > (
1340- sql `/* getMyOrganization */ SELECT * FROM organizations WHERE user_id = ${ user } AND type = ${ 'PERSONAL' } LIMIT 1` ,
1341- ) ;
1342-
1343- return org ? transformOrganization ( org ) : null ;
1344- } ,
13451338 async getOrganizations ( { userId : user } ) {
13461339 const results = await pool . query < Slonik < organizations > > (
13471340 sql `/* getOrganizations */
You can’t perform that action at this time.
0 commit comments