1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-16 01:51:21 +01:00

Fix org manager check on export (#1906)

* Fix org manager check on export

* Fix filter typo from collection to cipher
This commit is contained in:
Chad Scharf 2022-03-14 15:34:22 -04:00 committed by GitHub
parent 72baf6deab
commit 76ddcfa2dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -224,12 +224,17 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var ciphers = await _cipherRepository.GetManyByUserIdAsync(userId, true);
var orgCiphers = ciphers.Where(c => c.OrganizationId == orgIdGuid);
var orgCipherIds = orgCiphers.Select(c => c.Id);
var collectionCiphers = await _collectionCipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
var collectionCiphersGroupDict = collectionCiphers
.Where(c => orgCipherIds.Contains(c.CipherId))
.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, _globalSettings,
var responses = orgCiphers.Select(c => new CipherMiniDetailsResponseModel(c, _globalSettings,
collectionCiphersGroupDict));
var providerId = await _currentContext.ProviderIdForOrg(orgIdGuid);

View File

@ -87,8 +87,9 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
var collections = await _collectionRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var responses = collections.Select(c => new CollectionResponseModel(c));
var collections = await _collectionRepository.GetManyByUserIdAsync(_currentContext.UserId.Value);
var orgCollections = collections.Where(c => c.OrganizationId == orgIdGuid);
var responses = orgCollections.Select(c => new CollectionResponseModel(c));
return new ListResponseModel<CollectionResponseModel>(responses);
}