From e23f37ea1fbc1b32d689c07e30095707d1c40e47 Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:53:50 -0600 Subject: [PATCH] [AC-2214] Defect - provider reseller org creation when fc signup flag enabled (#3805) * fix: supply signup feature flag to provider reseller org creation, refs AC-2214 * feat: extend flexible collections coverage to enhancement bools, refs AC-2214 --- src/Admin/Controllers/ProvidersController.cs | 10 ++++++++-- src/Admin/Models/OrganizationEditModel.cs | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Admin/Controllers/ProvidersController.cs b/src/Admin/Controllers/ProvidersController.cs index 8fa02e9b3..949342873 100644 --- a/src/Admin/Controllers/ProvidersController.cs +++ b/src/Admin/Controllers/ProvidersController.cs @@ -1,6 +1,7 @@ using Bit.Admin.Enums; using Bit.Admin.Models; using Bit.Admin.Utilities; +using Bit.Core; using Bit.Core.AdminConsole.Entities.Provider; using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Providers.Interfaces; @@ -31,6 +32,7 @@ public class ProvidersController : Controller private readonly IReferenceEventService _referenceEventService; private readonly IUserService _userService; private readonly ICreateProviderCommand _createProviderCommand; + private readonly IFeatureService _featureService; public ProvidersController( IOrganizationRepository organizationRepository, @@ -43,7 +45,8 @@ public class ProvidersController : Controller IApplicationCacheService applicationCacheService, IReferenceEventService referenceEventService, IUserService userService, - ICreateProviderCommand createProviderCommand) + ICreateProviderCommand createProviderCommand, + IFeatureService featureService) { _organizationRepository = organizationRepository; _organizationService = organizationService; @@ -56,6 +59,7 @@ public class ProvidersController : Controller _referenceEventService = referenceEventService; _userService = userService; _createProviderCommand = createProviderCommand; + _featureService = featureService; } [RequirePermission(Permission.Provider_List_View)] @@ -236,7 +240,9 @@ public class ProvidersController : Controller return RedirectToAction("Index"); } - var organization = model.CreateOrganization(provider); + var flexibleCollectionsSignupEnabled = _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsSignup); + var flexibleCollectionsV1Enabled = _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1); + var organization = model.CreateOrganization(provider, flexibleCollectionsSignupEnabled, flexibleCollectionsV1Enabled); await _organizationService.CreatePendingOrganization(organization, model.Owners, User, _userService, model.SalesAssistedTrialStarted); await _providerService.AddOrganization(providerId, organization.Id, null); diff --git a/src/Admin/Models/OrganizationEditModel.cs b/src/Admin/Models/OrganizationEditModel.cs index 559b5b686..643b252f6 100644 --- a/src/Admin/Models/OrganizationEditModel.cs +++ b/src/Admin/Models/OrganizationEditModel.cs @@ -164,11 +164,22 @@ public class OrganizationEditModel : OrganizationViewModel { "baseServiceAccount", p.SecretsManager.BaseServiceAccount } }); - public Organization CreateOrganization(Provider provider) + public Organization CreateOrganization(Provider provider, bool flexibleCollectionsSignupEnabled, bool flexibleCollectionsV1Enabled) { BillingEmail = provider.BillingEmail; - return ToOrganization(new Organization()); + var newOrg = new Organization + { + // This feature flag indicates that new organizations should be automatically onboarded to + // Flexible Collections enhancements + FlexibleCollections = flexibleCollectionsSignupEnabled, + // These collection management settings smooth the migration for existing organizations by disabling some FC behavior. + // If the organization is onboarded to Flexible Collections on signup, we turn them OFF to enable all new behaviour. + // If the organization is NOT onboarded now, they will have to be migrated later, so they default to ON to limit FC changes on migration. + LimitCollectionCreationDeletion = !flexibleCollectionsSignupEnabled, + AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1Enabled + }; + return ToOrganization(newOrg); } public Organization ToOrganization(Organization existingOrganization)