mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 17:12:49 -05:00
Finish changing to property
This commit is contained in:
@ -47,6 +47,8 @@ public class CollectionsController : Controller
|
|||||||
_featureService = featureService;
|
_featureService = featureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public async Task<CollectionResponseModel> Get(Guid orgId, Guid id)
|
public async Task<CollectionResponseModel> Get(Guid orgId, Guid id)
|
||||||
{
|
{
|
||||||
@ -157,7 +159,7 @@ public class CollectionsController : Controller
|
|||||||
{
|
{
|
||||||
var collection = model.ToCollection(orgId);
|
var collection = model.ToCollection(orgId);
|
||||||
|
|
||||||
var authorized = FlexibleCollectionsIsEnabled()
|
var authorized = FlexibleCollectionsIsEnabled
|
||||||
? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Create)).Succeeded
|
? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Create)).Succeeded
|
||||||
: await CanCreateCollection(orgId, collection.Id) || await CanEditCollectionAsync(orgId, collection.Id);
|
: await CanCreateCollection(orgId, collection.Id) || await CanEditCollectionAsync(orgId, collection.Id);
|
||||||
if (!authorized)
|
if (!authorized)
|
||||||
@ -233,7 +235,7 @@ public class CollectionsController : Controller
|
|||||||
{
|
{
|
||||||
var collection = await GetCollectionAsync(id, orgId);
|
var collection = await GetCollectionAsync(id, orgId);
|
||||||
|
|
||||||
var authorized = FlexibleCollectionsIsEnabled()
|
var authorized = FlexibleCollectionsIsEnabled
|
||||||
? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Delete)).Succeeded
|
? (await _authorizationService.AuthorizeAsync(User, collection, CollectionOperations.Delete)).Succeeded
|
||||||
: await CanDeleteCollectionAsync(orgId, id);
|
: await CanDeleteCollectionAsync(orgId, id);
|
||||||
if (!authorized)
|
if (!authorized)
|
||||||
@ -248,7 +250,7 @@ public class CollectionsController : Controller
|
|||||||
[HttpPost("delete")]
|
[HttpPost("delete")]
|
||||||
public async Task DeleteMany(Guid orgId, [FromBody] CollectionBulkDeleteRequestModel model)
|
public async Task DeleteMany(Guid orgId, [FromBody] CollectionBulkDeleteRequestModel model)
|
||||||
{
|
{
|
||||||
if (FlexibleCollectionsIsEnabled())
|
if (FlexibleCollectionsIsEnabled)
|
||||||
{
|
{
|
||||||
// New flexible collections logic
|
// New flexible collections logic
|
||||||
var collections = await _collectionRepository.GetManyByManyIdsAsync(model.Ids);
|
var collections = await _collectionRepository.GetManyByManyIdsAsync(model.Ids);
|
||||||
@ -308,11 +310,9 @@ public class CollectionsController : Controller
|
|||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FlexibleCollectionsIsEnabled => _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
|
|
||||||
|
|
||||||
private void DeprecatedPermissionsGuard()
|
private void DeprecatedPermissionsGuard()
|
||||||
{
|
{
|
||||||
if (FlexibleCollectionsIsEnabled())
|
if (FlexibleCollectionsIsEnabled)
|
||||||
{
|
{
|
||||||
throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF.");
|
throw new FeatureUnavailableException("Flexible Collections is ON when it should be OFF.");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user