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

user can edit responses and cipher partial updates

This commit is contained in:
Kyle Spearrin
2017-03-24 16:15:50 -04:00
parent 84c5873cfd
commit 5029af33c5
17 changed files with 177 additions and 38 deletions

View File

@ -104,6 +104,15 @@ namespace Bit.Api.Controllers
// await _cipherService.SaveAsync(cipher);
//}
[HttpPut("{id}/partial")]
[HttpPost("{id}/partial")]
public async Task PutPartial(string id, [FromBody]CipherPartialRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
var folderId = string.IsNullOrWhiteSpace(model.FolderId) ? null : (Guid?)new Guid(model.FolderId);
await _cipherService.UpdatePartialAsync(new Guid(id), userId, folderId, model.Favorite);
}
[HttpPut("{id}/move")]
[HttpPost("{id}/move")]
public async Task PostMove(string id, [FromBody]CipherMoveRequestModel model)

View File

@ -31,16 +31,16 @@ namespace Bit.Api.Controllers
}
[HttpGet("{id}")]
public async Task<LoginResponseModel> Get(string id)
public async Task<LoginDetailsResponseModel> Get(string id)
{
var userId = _userService.GetProperUserId(User).Value;
var login = await _cipherRepository.GetByIdAsync(new Guid(id), userId);
var login = await _cipherRepository.GetFullDetailsByIdAsync(new Guid(id), userId);
if(login == null || login.Type != Core.Enums.CipherType.Login)
{
throw new NotFoundException();
}
var response = new LoginResponseModel(login);
var response = new LoginDetailsResponseModel(login);
return response;
}
@ -70,7 +70,7 @@ namespace Bit.Api.Controllers
public async Task<LoginResponseModel> Put(string id, [FromBody]LoginRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
var login = await _cipherRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value);
var login = await _cipherRepository.GetByIdAsync(new Guid(id), userId);
if(login == null || login.Type != Core.Enums.CipherType.Login)
{
throw new NotFoundException();