File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -224,8 +224,19 @@ public async Task<ListResponseModel<CipherMiniDetailsResponseModel>> GetOrganiza
224224 throw new NotFoundException ( ) ;
225225 }
226226
227- var ciphers = await _cipherRepository . GetManyByUserIdAsync ( userId , true ) ;
228- var orgCiphers = ciphers . Where ( c => c . OrganizationId == orgIdGuid ) ;
227+ IEnumerable < Cipher > orgCiphers ;
228+ if ( await _currentContext . OrganizationOwner ( orgIdGuid ) )
229+ {
230+ // User may be a Provider for the organization, in which case GetManyByUserIdAsync won't return any results
231+ // But they have access to all organization ciphers, so we can safely get by orgId instead
232+ orgCiphers = await _cipherRepository . GetManyByOrganizationIdAsync ( orgIdGuid ) ;
233+ }
234+ else
235+ {
236+ var ciphers = await _cipherRepository . GetManyByUserIdAsync ( userId , true ) ;
237+ orgCiphers = ciphers . Where ( c => c . OrganizationId == orgIdGuid ) ;
238+ }
239+
229240 var orgCipherIds = orgCiphers . Select ( c => c . Id ) ;
230241
231242 var collectionCiphers = await _collectionCipherRepository . GetManyByOrganizationIdAsync ( orgIdGuid ) ;
Original file line number Diff line number Diff line change @@ -87,8 +87,19 @@ public async Task<ListResponseModel<CollectionResponseModel>> Get(string orgId)
8787 throw new NotFoundException ( ) ;
8888 }
8989
90- var collections = await _collectionRepository . GetManyByUserIdAsync ( _currentContext . UserId . Value ) ;
91- var orgCollections = collections . Where ( c => c . OrganizationId == orgIdGuid ) ;
90+ IEnumerable < Collection > orgCollections ;
91+ if ( await _currentContext . OrganizationOwner ( orgIdGuid ) )
92+ {
93+ // User may be a Provider for the organization, in which case GetManyByUserIdAsync won't return any results
94+ // But they have access to all organization collections, so we can safely get by orgId instead
95+ orgCollections = await _collectionRepository . GetManyByOrganizationIdAsync ( orgIdGuid ) ;
96+ }
97+ else
98+ {
99+ var collections = await _collectionRepository . GetManyByUserIdAsync ( _currentContext . UserId . Value ) ;
100+ orgCollections = collections . Where ( c => c . OrganizationId == orgIdGuid ) ;
101+ }
102+
92103 var responses = orgCollections . Select ( c => new CollectionResponseModel ( c ) ) ;
93104 return new ListResponseModel < CollectionResponseModel > ( responses ) ;
94105 }
You can’t perform that action at this time.
0 commit comments