From 1a329638e0081a239ff495912aa279dbb32aafc7 Mon Sep 17 00:00:00 2001 From: Conner Turnbull <133619638+cturnbull-bitwarden@users.noreply.github.com> Date: Mon, 13 May 2024 12:17:36 -0400 Subject: [PATCH] Resolved issue where non-provider user couldn't access subscription page of managed organization (#9137) --- .../organization-subscription-cloud.component.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts index 198332db0c..d021c827a7 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts @@ -5,8 +5,7 @@ import { concatMap, firstValueFrom, lastValueFrom, Observable, Subject, takeUnti import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; -import { ProviderApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/provider/provider-api.service.abstraction"; -import { OrganizationApiKeyType, ProviderType } from "@bitwarden/common/admin-console/enums"; +import { OrganizationApiKeyType } from "@bitwarden/common/admin-console/enums"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { PlanType } from "@bitwarden/common/billing/enums"; import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/models/response/organization-subscription.response"; @@ -70,7 +69,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy private route: ActivatedRoute, private dialogService: DialogService, private configService: ConfigService, - private providerService: ProviderApiServiceAbstraction, ) {} async ngOnInit() { @@ -108,15 +106,15 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy this.loading = true; this.locale = await firstValueFrom(this.i18nService.locale$); this.userOrg = await this.organizationService.get(this.organizationId); - if (this.userOrg.hasProvider) { - const provider = await this.providerService.getProvider(this.userOrg.providerId); - const enableConsolidatedBilling = await firstValueFrom(this.enableConsolidatedBilling$); - this.isProviderManaged = provider.type == ProviderType.Msp && enableConsolidatedBilling; - } if (this.userOrg.canViewSubscription) { + const enableConsolidatedBilling = await firstValueFrom(this.enableConsolidatedBilling$); + + this.isProviderManaged = enableConsolidatedBilling && this.userOrg.hasProvider; + this.sub = await this.organizationApiService.getSubscription(this.organizationId); this.lineItems = this.sub?.subscription?.items; + if (this.lineItems && this.lineItems.length) { this.lineItems = this.lineItems .map((item) => {