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

apis for org vault listing

This commit is contained in:
Kyle Spearrin
2017-04-17 17:01:23 -04:00
parent 5b76c43fb0
commit 0e5799f7c8
10 changed files with 118 additions and 7 deletions

View File

@ -85,6 +85,25 @@ namespace Bit.Api.Controllers
return new ListResponseModel<CipherDetailsResponseModel>(responses);
}
[HttpGet("organization-details")]
public async Task<ListResponseModel<CipherMiniDetailsResponseModel>> GetOrganizationSubvaults(string organizationId)
{
var userId = _userService.GetProperUserId(User).Value;
var orgIdGuid = new Guid(organizationId);
if(!_currentContext.OrganizationAdmin(orgIdGuid))
{
throw new NotFoundException();
}
var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var subvaultCiphers = await _subvaultCipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var subvaultCiphersGroupDict = subvaultCiphers.GroupBy(s => s.CipherId).ToDictionary(s => s.Key);
var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, subvaultCiphersGroupDict));
return new ListResponseModel<CipherMiniDetailsResponseModel>(responses);
}
[Obsolete]
[HttpGet("history")]
public Task<CipherHistoryResponseModel> Get(DateTime since)
@ -116,7 +135,7 @@ namespace Bit.Api.Controllers
{
throw new NotFoundException();
}
await _cipherService.UpdatePartialAsync(new Guid(id), userId, cipher.FolderId, !cipher.Favorite);
}