Browse Source

Fix org manager check on export (#1906)

* Fix org manager check on export

* Fix filter typo from collection to cipher
pull/1911/head
Chad Scharf 4 years ago committed by GitHub
parent
commit
76ddcfa2dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/Api/Controllers/CiphersController.cs
  2. 5
      src/Api/Controllers/CollectionsController.cs

11
src/Api/Controllers/CiphersController.cs

@ -224,12 +224,17 @@ namespace Bit.Api.Controllers @@ -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);

5
src/Api/Controllers/CollectionsController.cs

@ -87,8 +87,9 @@ namespace Bit.Api.Controllers @@ -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);
}

Loading…
Cancel
Save