1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 17:12:49 -05:00

return share information with cipher API response

This commit is contained in:
Kyle Spearrin
2017-02-21 22:52:02 -05:00
parent 8051995cc7
commit 900e71d4dd
11 changed files with 123 additions and 15 deletions

View File

@ -31,27 +31,28 @@ namespace Bit.Api.Controllers
}
[HttpGet("{id}")]
public async Task<CipherResponseModel> Get(string id)
public async Task<CipherShareResponseModel> Get(string id)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId);
var cipher = await _cipherRepository.GetShareByIdAsync(new Guid(id), userId);
if(cipher == null)
{
throw new NotFoundException();
}
return new CipherResponseModel(cipher, userId);
return new CipherShareResponseModel(cipher, userId);
}
[HttpGet("")]
public async Task<ListResponseModel<CipherResponseModel>> Get()
public async Task<ListResponseModel<CipherShareResponseModel>> Get()
{
var userId = _userService.GetProperUserId(User).Value;
var ciphers = await _cipherRepository.GetManyByUserIdAsync(userId);
var responses = ciphers.Select(c => new CipherResponseModel(c, userId));
return new ListResponseModel<CipherResponseModel>(responses);
var ciphers = await _cipherRepository.GetManyShareByUserIdAsync(userId);
var responses = ciphers.Select(c => new CipherShareResponseModel(c, userId));
return new ListResponseModel<CipherShareResponseModel>(responses);
}
[Obsolete]
[HttpGet("history")]
public async Task<CipherHistoryResponseModel> Get(DateTime since)
{