1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-24 17:17:40 +01:00

return cipher model with share put

This commit is contained in:
Kyle Spearrin 2018-10-23 16:12:31 -04:00
parent 8bd6d830e6
commit 5bc07fea7e

View File

@ -265,10 +265,11 @@ namespace Bit.Api.Controllers
[HttpPut("{id}/share")]
[HttpPost("{id}/share")]
public async Task PutShare(string id, [FromBody]CipherShareRequestModel model)
public async Task<CipherResponseModel> PutShare(string id, [FromBody]CipherShareRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id));
var cipherId = new Guid(id);
var cipher = await _cipherRepository.GetByIdAsync(cipherId);
if(cipher == null || cipher.UserId != userId ||
!_currentContext.OrganizationUser(new Guid(model.Cipher.OrganizationId)))
{
@ -278,6 +279,10 @@ namespace Bit.Api.Controllers
var original = CoreHelpers.CloneObject(cipher);
await _cipherService.ShareAsync(original, model.Cipher.ToCipher(cipher),
new Guid(model.Cipher.OrganizationId), model.CollectionIds.Select(c => new Guid(c)), userId);
var sharedCipher = await _cipherRepository.GetByIdAsync(cipherId, userId);
var response = new CipherResponseModel(sharedCipher, _globalSettings);
return response;
}
[HttpPut("{id}/collections")]