File tree Expand file tree Collapse file tree 5 files changed +25
-14
lines changed Expand file tree Collapse file tree 5 files changed +25
-14
lines changed 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 {
78
78
return this . storage . getOrganization ( selector ) ;
79
79
}
80
80
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
+
81
97
async getOrganizationBySlug ( organizationSlug : string ) : Promise < Organization | null > {
82
98
const organization = await this . storage . getOrganizationBySlug ( { slug : organizationSlug } ) ;
83
99
Original file line number Diff line number Diff line change @@ -41,16 +41,14 @@ export const myDefaultOrganization: NonNullable<QueryResolvers['myDefaultOrganiz
41
41
} ) ;
42
42
43
43
if ( orgId ) {
44
- const org = await organizationManager . getOrganization ( {
45
- organizationId : orgId ,
46
- } ) ;
44
+ const organization = await organizationManager . getOrganizationOrNull ( orgId ) ;
47
45
48
- if ( org ) {
46
+ if ( organization ) {
49
47
return {
50
48
selector : {
51
- organizationSlug : org . slug ,
49
+ organizationSlug : organization . slug ,
52
50
} ,
53
- organization : org ,
51
+ organization,
54
52
} ;
55
53
}
56
54
}
Original file line number Diff line number Diff line change @@ -92,7 +92,6 @@ export interface Storage {
92
92
installationId : string ;
93
93
} ) : Promise < Organization | null > ;
94
94
getOrganization ( _ : { organizationId : string } ) : Promise < Organization | never > ;
95
- getMyOrganization ( _ : { userId : string } ) : Promise < Organization | null > ;
96
95
getOrganizations ( _ : { userId : string } ) : Promise < readonly Organization [ ] | never > ;
97
96
createOrganization (
98
97
_ : Pick < Organization , 'slug' > & {
Original file line number Diff line number Diff line change @@ -1335,13 +1335,6 @@ export async function createStorage(
1335
1335
) ,
1336
1336
) ;
1337
1337
} ,
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
- } ,
1345
1338
async getOrganizations ( { userId : user } ) {
1346
1339
const results = await pool . query < Slonik < organizations > > (
1347
1340
sql `/* getOrganizations */
You can’t perform that action at this time.
0 commit comments