Skip to content

Commit

Permalink
return cipher from collections endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-livefront committed Oct 31, 2024
1 parent f70bfc2 commit 6be2b67
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Api/Vault/Controllers/CiphersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,10 @@ await _cipherService.SaveCollectionsAsync(cipher,

[HttpPut("{id}/collections-admin")]
[HttpPost("{id}/collections-admin")]
public async Task PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id));
var cipher = await _cipherRepository.GetOrganizationDetailsByIdAsync(new Guid(id));

Check warning on line 609 in src/Api/Vault/Controllers/CiphersController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Vault/Controllers/CiphersController.cs#L609

Added line #L609 was not covered by tests

if (cipher == null || !cipher.OrganizationId.HasValue ||
!await CanEditCipherAsAdminAsync(cipher.OrganizationId.Value, new[] { cipher.Id }))
Expand All @@ -624,6 +624,11 @@ public async Task PutCollectionsAdmin(string id, [FromBody] CipherCollectionsReq
}

await _cipherService.SaveCollectionsAsync(cipher, collectionIds, userId, true);

var collectionCiphers = await _collectionCipherRepository.GetManyByOrganizationIdAsync(cipher.OrganizationId.Value);
var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);

Check warning on line 629 in src/Api/Vault/Controllers/CiphersController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Vault/Controllers/CiphersController.cs#L628-L629

Added lines #L628 - L629 were not covered by tests

return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp);

Check warning on line 631 in src/Api/Vault/Controllers/CiphersController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Vault/Controllers/CiphersController.cs#L631

Added line #L631 was not covered by tests
}

[HttpPost("bulk-collections")]
Expand Down

0 comments on commit 6be2b67

Please sign in to comment.