1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

[PS-165] Missing copy verification code (#2022)

* Made changes to organization details endpoint

* Fixed formatting

* Added script to utils directory
This commit is contained in:
Gbubemi Smith
2022-06-07 16:52:07 +01:00
committed by GitHub
parent 60a167f2b7
commit 64edad8f49
9 changed files with 123 additions and 7 deletions

View File

@ -224,11 +224,12 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
IEnumerable<Cipher> orgCiphers;
if (await _currentContext.OrganizationAdmin(orgIdGuid))
IEnumerable<CipherOrganizationDetails> orgCiphers;
if (await _currentContext.OrganizationOwner(orgIdGuid))
{
// Admins, Owners and Providers can access all items even if not assigned to them
orgCiphers = await _cipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
// User may be a Provider for the organization, in which case GetManyByUserIdAsync won't return any results
// But they have access to all organization ciphers, so we can safely get by orgId instead
orgCiphers = await _cipherRepository.GetManyOrganizationDetailsByOrganizationIdAsync(orgIdGuid);
}
else
{
@ -245,7 +246,8 @@ namespace Bit.Api.Controllers
var responses = orgCiphers.Select(c => new CipherMiniDetailsResponseModel(c, _globalSettings,
collectionCiphersGroupDict));
collectionCiphersGroupDict, c.OrganizationUseTotp));
var providerId = await _currentContext.ProviderIdForOrg(orgIdGuid);
if (providerId.HasValue)

View File

@ -132,8 +132,8 @@ namespace Bit.Api.Models.Response
public class CipherMiniDetailsResponseModel : CipherMiniResponseModel
{
public CipherMiniDetailsResponseModel(Cipher cipher, GlobalSettings globalSettings,
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, string obj = "cipherMiniDetails")
: base(cipher, globalSettings, false, obj)
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphers, bool orgUseTotp, string obj = "cipherMiniDetails")
: base(cipher, globalSettings, orgUseTotp, obj)
{
if (collectionCiphers?.ContainsKey(cipher.Id) ?? false)
{