1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 01:22:50 -05:00

[PM-22344] - fix Error: Cannot Decrypt when moving a vault item to a collection (#5911)

* use ToCipher instead of casting

* return ListResponseModel

* fix test

* remove ToArray

* have ShareManyAsync return CipherDetails

* fix test

* fix tests

* fix test

* fix test
This commit is contained in:
Jordan Aasen
2025-06-03 14:02:13 -07:00
committed by GitHub
parent 812fe94c16
commit 2e14a46cee
5 changed files with 46 additions and 24 deletions

View File

@ -1064,7 +1064,7 @@ public class CiphersController : Controller
[HttpPut("share")]
[HttpPost("share")]
public async Task<CipherMiniResponseModel[]> PutShareMany([FromBody] CipherBulkShareRequestModel model)
public async Task<ListResponseModel<CipherMiniResponseModel>> PutShareMany([FromBody] CipherBulkShareRequestModel model)
{
var organizationId = new Guid(model.Ciphers.First().OrganizationId);
if (!await _currentContext.OrganizationUser(organizationId))
@ -1086,7 +1086,7 @@ public class CiphersController : Controller
}
}
var shareCiphers = new List<(Cipher, DateTime?)>();
var shareCiphers = new List<(CipherDetails, DateTime?)>();
foreach (var cipher in model.Ciphers)
{
if (!ciphersDict.TryGetValue(cipher.Id.Value, out var existingCipher))
@ -1096,7 +1096,7 @@ public class CiphersController : Controller
ValidateClientVersionForFido2CredentialSupport(existingCipher);
shareCiphers.Add(((Cipher)existingCipher, cipher.LastKnownRevisionDate));
shareCiphers.Add((cipher.ToCipherDetails(existingCipher), cipher.LastKnownRevisionDate));
}
var updated = await _cipherService.ShareManyAsync(
@ -1106,7 +1106,8 @@ public class CiphersController : Controller
userId
);
return updated.Select(c => new CipherMiniResponseModel(c, _globalSettings, false)).ToArray();
var response = updated.Select(c => new CipherMiniResponseModel(c, _globalSettings, c.OrganizationUseTotp));
return new ListResponseModel<CipherMiniResponseModel>(response);
}
[HttpPost("purge")]