mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Ps 976 moving of read only organization collection items to different folder not possible (#2257)
* PS-976 - update PutPartial endpoint to return cipher info, update Cipher_Move sproc to allow users to update a cipher's folder even if they don't have edit permissions * PS-976- fix formatting errors * PS-976 - per cr feedback updated EF query to match cipher_move sproc update, and updated cipher tests to align with existing tests
This commit is contained in:
@ -272,11 +272,16 @@ public class CiphersController : Controller
|
||||
|
||||
[HttpPut("{id}/partial")]
|
||||
[HttpPost("{id}/partial")]
|
||||
public async Task PutPartial(string id, [FromBody] CipherPartialRequestModel model)
|
||||
public async Task<CipherResponseModel> 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 _cipherRepository.UpdatePartialAsync(new Guid(id), userId, folderId, model.Favorite);
|
||||
var cipherId = new Guid(id);
|
||||
await _cipherRepository.UpdatePartialAsync(cipherId, userId, folderId, model.Favorite);
|
||||
|
||||
var cipher = await _cipherRepository.GetByIdAsync(cipherId, userId);
|
||||
var response = new CipherResponseModel(cipher, _globalSettings);
|
||||
return response;
|
||||
}
|
||||
|
||||
[HttpPut("{id}/share")]
|
||||
|
@ -345,7 +345,6 @@ public class CipherRepository : Repository<Core.Entities.Cipher, Cipher, Guid>,
|
||||
var idsToMove = from ucd in userCipherDetails
|
||||
join c in cipherEntities
|
||||
on ucd.Id equals c.Id
|
||||
where ucd.Edit
|
||||
select c;
|
||||
await idsToMove.ForEachAsync(cipher =>
|
||||
{
|
||||
|
@ -15,8 +15,7 @@ BEGIN
|
||||
FROM
|
||||
[dbo].[UserCipherDetails](@UserId)
|
||||
WHERE
|
||||
[Edit] = 1
|
||||
AND [Id] IN (SELECT * FROM @Ids)
|
||||
[Id] IN (SELECT * FROM @Ids)
|
||||
)
|
||||
UPDATE
|
||||
[dbo].[Cipher]
|
||||
|
Reference in New Issue
Block a user