Skip to content

Commit

Permalink
[PM-13783] Battle harden ProviderType enum expansion (#5004)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Bishop <[email protected]>
  • Loading branch information
jonashendrickx and withinfocus authored Nov 13, 2024
1 parent b177624 commit 6f7cdcf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Core/Billing/Extensions/BillingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public static bool IsBillable(this Provider provider) =>
provider.SupportsConsolidatedBilling() && provider.Status == ProviderStatusType.Billable;

public static bool SupportsConsolidatedBilling(this Provider provider)
=> provider.Type is ProviderType.Msp or ProviderType.MultiOrganizationEnterprise;
=> provider.Type.SupportsConsolidatedBilling();

public static bool SupportsConsolidatedBilling(this ProviderType providerType)
=> providerType is ProviderType.Msp or ProviderType.MultiOrganizationEnterprise;

public static bool IsValidClient(this Organization organization)
=> organization is
Expand Down
5 changes: 3 additions & 2 deletions src/Core/Context/CurrentContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Bit.Core.AdminConsole.Enums.Provider;
using Bit.Core.AdminConsole.Models.Data.Provider;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Billing.Extensions;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Identity;
Expand Down Expand Up @@ -363,9 +364,9 @@ public async Task<bool> ManageResetPassword(Guid orgId)

public async Task<bool> ViewSubscription(Guid orgId)
{
var orgManagedByMspProvider = (await GetOrganizationProviderDetails()).Any(po => po.OrganizationId == orgId && po.ProviderType == ProviderType.Msp);
var isManagedByBillableProvider = (await GetOrganizationProviderDetails()).Any(po => po.OrganizationId == orgId && po.ProviderType.SupportsConsolidatedBilling());

return orgManagedByMspProvider
return isManagedByBillableProvider
? await ProviderUserForOrgAsync(orgId)
: await OrganizationOwner(orgId);
}
Expand Down

0 comments on commit 6f7cdcf

Please sign in to comment.