1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

[PM-13783] Battle harden ProviderType enum expansion (#5004)

Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
This commit is contained in:
Jonas Hendrickx 2024-11-13 15:01:26 +01:00 committed by GitHub
parent b1776240ea
commit 6f7cdcfcea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -14,7 +14,10 @@ public static class BillingExtensions
provider.SupportsConsolidatedBilling() && provider.Status == ProviderStatusType.Billable; provider.SupportsConsolidatedBilling() && provider.Status == ProviderStatusType.Billable;
public static bool SupportsConsolidatedBilling(this Provider provider) 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) public static bool IsValidClient(this Organization organization)
=> organization is => organization is

View File

@ -3,6 +3,7 @@ using Bit.Core.AdminConsole.Context;
using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Enums.Provider;
using Bit.Core.AdminConsole.Models.Data.Provider; using Bit.Core.AdminConsole.Models.Data.Provider;
using Bit.Core.AdminConsole.Repositories; using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Billing.Extensions;
using Bit.Core.Entities; using Bit.Core.Entities;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Identity; using Bit.Core.Identity;
@ -363,9 +364,9 @@ public class CurrentContext : ICurrentContext
public async Task<bool> ViewSubscription(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 ProviderUserForOrgAsync(orgId)
: await OrganizationOwner(orgId); : await OrganizationOwner(orgId);
} }