mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 19:05:07 -05:00
refactor for cipher details, folders, favorites
This commit is contained in:
@ -38,7 +38,7 @@ namespace Bit.Api.Controllers
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
return new CipherResponseModel(cipher, userId);
|
||||
return new CipherResponseModel(cipher);
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
@ -46,25 +46,25 @@ namespace Bit.Api.Controllers
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var ciphers = await _cipherRepository.GetManyByUserIdAsync(userId);
|
||||
var responses = ciphers.Select(c => new CipherResponseModel(c, userId));
|
||||
var responses = ciphers.Select(c => new CipherResponseModel(c));
|
||||
return new ListResponseModel<CipherResponseModel>(responses);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[HttpGet("history")]
|
||||
public async Task<CipherHistoryResponseModel> Get(DateTime since)
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var history = await _cipherRepository.GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(
|
||||
since, userId);
|
||||
return new CipherHistoryResponseModel(history.Item1, history.Item2, userId);
|
||||
}
|
||||
//[Obsolete]
|
||||
//[HttpGet("history")]
|
||||
//public async Task<CipherHistoryResponseModel> Get(DateTime since)
|
||||
//{
|
||||
// var userId = _userService.GetProperUserId(User).Value;
|
||||
// var history = await _cipherRepository.GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(
|
||||
// since, userId);
|
||||
// return new CipherHistoryResponseModel(history.Item1, history.Item2, userId);
|
||||
//}
|
||||
|
||||
[HttpPost("import")]
|
||||
public async Task PostImport([FromBody]ImportRequestModel model)
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var folderCiphers = model.Folders.Select(f => f.ToCipher(userId)).ToList();
|
||||
var folderCiphers = model.Folders.Select(f => f.ToFolder(userId)).ToList();
|
||||
var otherCiphers = model.Logins.Select(s => s.ToCipher(userId)).ToList();
|
||||
|
||||
await _cipherService.ImportCiphersAsync(
|
||||
@ -73,20 +73,20 @@ namespace Bit.Api.Controllers
|
||||
model.FolderRelationships);
|
||||
}
|
||||
|
||||
[HttpPut("{id}/favorite")]
|
||||
[HttpPost("{id}/favorite")]
|
||||
public async Task Favorite(string id)
|
||||
{
|
||||
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value);
|
||||
if(cipher == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
//[HttpPut("{id}/favorite")]
|
||||
//[HttpPost("{id}/favorite")]
|
||||
//public async Task Favorite(string id)
|
||||
//{
|
||||
// var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value);
|
||||
// if(cipher == null)
|
||||
// {
|
||||
// throw new NotFoundException();
|
||||
// }
|
||||
|
||||
cipher.Favorite = !cipher.Favorite;
|
||||
// cipher.Favorite = !cipher.Favorite;
|
||||
|
||||
await _cipherService.SaveAsync(cipher);
|
||||
}
|
||||
// await _cipherService.SaveAsync(cipher);
|
||||
//}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[HttpPost("{id}/delete")]
|
||||
|
Reference in New Issue
Block a user