1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-21 16:18:28 +01:00

Resolved issue where non-provider user couldn't access subscription page of managed organization (#9137)

This commit is contained in:
Conner Turnbull 2024-05-13 12:17:36 -04:00 committed by GitHub
parent 5092151b54
commit 1a329638e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) => {