Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 55 additions & 6 deletions src/Api/Vault/Controllers/CiphersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,14 @@ public async Task<CipherResponseModel> PostShare(Guid id, [FromBody] CipherShare
}

[HttpPut("{id}/collections")]
[Obsolete("Replaced by /shared-folders route; retained for backwards compatibility")]
public async Task<CipherDetailsResponseModel> PutCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutSharedFolders(id, model);
}

[HttpPut("{id}/shared-folders")]
public async Task<CipherDetailsResponseModel> PutSharedFolders(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
var cipher = await GetByIdAsync(id, user.Id);
Expand All @@ -780,14 +787,28 @@ await _cipherService.SaveCollectionsAsync(cipher,
}

[HttpPost("{id}/collections")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
[Obsolete("Replaced by /shared-folders route; retained for backwards compatibility")]
public async Task<CipherDetailsResponseModel> PostCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollections(id, model);
return await PutSharedFolders(id, model);
}

[HttpPost("{id}/shared-folders")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherDetailsResponseModel> PostSharedFolders(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutSharedFolders(id, model);
}

[HttpPut("{id}/collections_v2")]
[Obsolete("Replaced by /shared-folders route; retained for backwards compatibility")]
public async Task<OptionalCipherDetailsResponseModel> PutCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutSharedFolders_vNext(id, model);
}

[HttpPut("{id}/shared-folders_v2")]
public async Task<OptionalCipherDetailsResponseModel> PutSharedFolders_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
var cipher = await GetByIdAsync(id, user.Id);
Expand Down Expand Up @@ -815,14 +836,28 @@ await _cipherService.SaveCollectionsAsync(cipher,
}

[HttpPost("{id}/collections_v2")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
[Obsolete("Replaced by /shared-folders route; retained for backwards compatibility")]
public async Task<OptionalCipherDetailsResponseModel> PostCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollections_vNext(id, model);
return await PutSharedFolders_vNext(id, model);
}

[HttpPost("{id}/shared-folders_v2")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<OptionalCipherDetailsResponseModel> PostSharedFolders_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutSharedFolders_vNext(id, model);
}

[HttpPut("{id}/collections-admin")]
[Obsolete("Replaced by /shared-folders route; retained for backwards compatibility")]
public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutSharedFoldersAdmin(id, model);
}

[HttpPut("{id}/shared-folders-admin")]
public async Task<CipherMiniDetailsResponseModel> PutSharedFoldersAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetOrganizationDetailsByIdAsync(new Guid(id));
Expand Down Expand Up @@ -851,14 +886,28 @@ public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id,
}

[HttpPost("{id}/collections-admin")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
[Obsolete("Replaced by /shared-folders route; retained for backwards compatibility")]
public async Task<CipherMiniDetailsResponseModel> PostCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollectionsAdmin(id, model);
return await PutSharedFoldersAdmin(id, model);
}

[HttpPost("{id}/shared-folders-admin")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherMiniDetailsResponseModel> PostSharedFoldersAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutSharedFoldersAdmin(id, model);
}

[HttpPost("bulk-collections")]
[Obsolete("Replaced by /shared-folders route; retained for backwards compatibility")]
public async Task PostBulkCollections([FromBody] CipherBulkUpdateCollectionsRequestModel model)
{
await PostBulkSharedFolders(model);
}

[HttpPost("bulk-shared-folders")]
public async Task PostBulkSharedFolders([FromBody] CipherBulkUpdateCollectionsRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
await _cipherService.ValidateBulkCollectionAssignmentAsync(model.CollectionIds, model.CipherIds, userId);
Expand Down
Loading
Loading