Skip to content

Commit

Permalink
[AC-1122] Use V1 feature flag for new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-melton committed Nov 13, 2023
1 parent b1f2d4f commit 46437b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/Api/AdminConsole/Controllers/OrganizationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Constants = Microsoft.VisualBasic.Constants;

Check warning on line 32 in src/Api/AdminConsole/Controllers/OrganizationsController.cs

View workflow job for this annotation

GitHub Actions / Lint

Using directive is unnecessary.

namespace Bit.Api.AdminConsole.Controllers;

Expand Down Expand Up @@ -794,6 +795,14 @@ public async Task<OrganizationResponseModel> PutCollectionManagement(Guid id, [F
throw new NotFoundException();
}

var v1Enabled = _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1, _currentContext);

if (!v1Enabled)
{
// V1 is disabled, ensure V1 setting doesn't change
model.AllowAdminAccessToAllCollectionItems = organization.AllowAdminAccessToAllCollectionItems;
}

await _organizationService.UpdateAsync(model.ToOrganization(organization));
return new OrganizationResponseModel(organization);
}
Expand Down
1 change: 1 addition & 0 deletions src/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static class FeatureFlagKeys
public const string AutofillV2 = "autofill-v2";
public const string BrowserFilelessImport = "browser-fileless-import";
public const string FlexibleCollections = "flexible-collections";
public const string FlexibleCollectionsV1 = "flexible-collections-v-1"; // v-1 is intentional
public const string BulkCollectionAccess = "bulk-collection-access";
public const string AutofillOverlay = "autofill-overlay";
public const string ItemShare = "item-share";
Expand Down
4 changes: 3 additions & 1 deletion src/Core/Services/Implementations/OrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ public async Task<Tuple<Organization, OrganizationUser>> SignUpAsync(Organizatio

var flexibleCollectionsIsEnabled =
_featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext);
var flexibleCollectionsV1IsEnabled =
_featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1, _currentContext);

var organization = new Organization
{
Expand Down Expand Up @@ -473,7 +475,7 @@ public async Task<Tuple<Organization, OrganizationUser>> SignUpAsync(Organizatio
UsePasswordManager = true,
UseSecretsManager = signup.UseSecretsManager,
LimitCollectionCreationDeletion = !flexibleCollectionsIsEnabled,
AllowAdminAccessToAllCollectionItems = !flexibleCollectionsIsEnabled
AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1IsEnabled
};

if (signup.UseSecretsManager)
Expand Down

0 comments on commit 46437b4

Please sign in to comment.