mirror of
https://github.com/bitwarden/server.git
synced 2024-11-21 12:05:42 +01:00
[PM-13646] Revert disabling policies when org plan is changed
This reverts commit fd8c1aae02
.
This commit is contained in:
parent
c643f8fd31
commit
a587de4226
@ -7,7 +7,6 @@ using Bit.Core;
|
|||||||
using Bit.Core.AdminConsole.Entities;
|
using Bit.Core.AdminConsole.Entities;
|
||||||
using Bit.Core.AdminConsole.Providers.Interfaces;
|
using Bit.Core.AdminConsole.Providers.Interfaces;
|
||||||
using Bit.Core.AdminConsole.Repositories;
|
using Bit.Core.AdminConsole.Repositories;
|
||||||
using Bit.Core.AdminConsole.Services;
|
|
||||||
using Bit.Core.Billing.Extensions;
|
using Bit.Core.Billing.Extensions;
|
||||||
using Bit.Core.Billing.Services;
|
using Bit.Core.Billing.Services;
|
||||||
using Bit.Core.Context;
|
using Bit.Core.Context;
|
||||||
@ -57,7 +56,6 @@ public class OrganizationsController : Controller
|
|||||||
private readonly IRemoveOrganizationFromProviderCommand _removeOrganizationFromProviderCommand;
|
private readonly IRemoveOrganizationFromProviderCommand _removeOrganizationFromProviderCommand;
|
||||||
private readonly IFeatureService _featureService;
|
private readonly IFeatureService _featureService;
|
||||||
private readonly IProviderBillingService _providerBillingService;
|
private readonly IProviderBillingService _providerBillingService;
|
||||||
private readonly IPolicyService _policyService;
|
|
||||||
|
|
||||||
public OrganizationsController(
|
public OrganizationsController(
|
||||||
IOrganizationService organizationService,
|
IOrganizationService organizationService,
|
||||||
@ -84,8 +82,7 @@ public class OrganizationsController : Controller
|
|||||||
IProviderOrganizationRepository providerOrganizationRepository,
|
IProviderOrganizationRepository providerOrganizationRepository,
|
||||||
IRemoveOrganizationFromProviderCommand removeOrganizationFromProviderCommand,
|
IRemoveOrganizationFromProviderCommand removeOrganizationFromProviderCommand,
|
||||||
IFeatureService featureService,
|
IFeatureService featureService,
|
||||||
IProviderBillingService providerBillingService,
|
IProviderBillingService providerBillingService)
|
||||||
IPolicyService policyService)
|
|
||||||
{
|
{
|
||||||
_organizationService = organizationService;
|
_organizationService = organizationService;
|
||||||
_organizationRepository = organizationRepository;
|
_organizationRepository = organizationRepository;
|
||||||
@ -112,7 +109,6 @@ public class OrganizationsController : Controller
|
|||||||
_removeOrganizationFromProviderCommand = removeOrganizationFromProviderCommand;
|
_removeOrganizationFromProviderCommand = removeOrganizationFromProviderCommand;
|
||||||
_featureService = featureService;
|
_featureService = featureService;
|
||||||
_providerBillingService = providerBillingService;
|
_providerBillingService = providerBillingService;
|
||||||
_policyService = policyService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequirePermission(Permission.Org_List_View)]
|
[RequirePermission(Permission.Org_List_View)]
|
||||||
@ -440,13 +436,6 @@ public class OrganizationsController : Controller
|
|||||||
organization.MaxAutoscaleSmServiceAccounts = model.MaxAutoscaleSmServiceAccounts;
|
organization.MaxAutoscaleSmServiceAccounts = model.MaxAutoscaleSmServiceAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
var plan = StaticStore.GetPlan(organization.PlanType);
|
|
||||||
|
|
||||||
if (!organization.UsePolicies || !plan.HasPolicies)
|
|
||||||
{
|
|
||||||
await DisableOrganizationPoliciesAsync(organization.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_accessControlService.UserHasPermission(Permission.Org_Licensing_Edit))
|
if (_accessControlService.UserHasPermission(Permission.Org_Licensing_Edit))
|
||||||
{
|
{
|
||||||
organization.LicenseKey = model.LicenseKey;
|
organization.LicenseKey = model.LicenseKey;
|
||||||
@ -463,18 +452,4 @@ public class OrganizationsController : Controller
|
|||||||
|
|
||||||
return organization;
|
return organization;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DisableOrganizationPoliciesAsync(Guid organizationId)
|
|
||||||
{
|
|
||||||
var policies = await _policyRepository.GetManyByOrganizationIdAsync(organizationId);
|
|
||||||
|
|
||||||
if (policies.Count != 0)
|
|
||||||
{
|
|
||||||
await Task.WhenAll(policies.Select(async policy =>
|
|
||||||
{
|
|
||||||
policy.Enabled = false;
|
|
||||||
await _policyService.SaveAsync(policy, _organizationService, null);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user