mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-12 19:50:46 +01:00
prevent access to freefamilies page (#12335)
This commit is contained in:
parent
83dc66dd56
commit
84dfa3ab05
@ -10,6 +10,7 @@ import {
|
||||
AsyncValidatorFn,
|
||||
ValidationErrors,
|
||||
} from "@angular/forms";
|
||||
import { Router } from "@angular/router";
|
||||
import { combineLatest, firstValueFrom, map, Observable, Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
@ -26,6 +27,8 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
|
||||
import { FreeFamiliesPolicyService } from "../services/free-families-policy.service";
|
||||
|
||||
interface RequestSponsorshipForm {
|
||||
selectedSponsorshipOrgId: FormControl<string>;
|
||||
sponsorshipEmail: FormControl<string>;
|
||||
@ -62,6 +65,8 @@ export class SponsoredFamiliesComponent implements OnInit, OnDestroy {
|
||||
private toastService: ToastService,
|
||||
private configService: ConfigService,
|
||||
private policyService: PolicyService,
|
||||
private freeFamiliesPolicyService: FreeFamiliesPolicyService,
|
||||
private router: Router,
|
||||
) {
|
||||
this.sponsorshipForm = this.formBuilder.group<RequestSponsorshipForm>({
|
||||
selectedSponsorshipOrgId: new FormControl("", {
|
||||
@ -86,6 +91,8 @@ export class SponsoredFamiliesComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
|
||||
if (this.isFreeFamilyFlagEnabled) {
|
||||
await this.preventAccessToFreeFamiliesPage();
|
||||
|
||||
this.availableSponsorshipOrgs$ = combineLatest([
|
||||
this.organizationService.organizations$,
|
||||
this.policyService.getAll$(PolicyType.FreeFamiliesSponsorshipPolicy),
|
||||
@ -142,6 +149,17 @@ export class SponsoredFamiliesComponent implements OnInit, OnDestroy {
|
||||
this._destroy.complete();
|
||||
}
|
||||
|
||||
private async preventAccessToFreeFamiliesPage() {
|
||||
const showFreeFamiliesPage = await firstValueFrom(
|
||||
this.freeFamiliesPolicyService.showFreeFamilies$,
|
||||
);
|
||||
|
||||
if (!showFreeFamiliesPage) {
|
||||
await this.router.navigate(["/"]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
submit = async () => {
|
||||
this.formPromise = this.apiService.postCreateSponsorship(
|
||||
this.sponsorshipForm.value.selectedSponsorshipOrgId,
|
||||
|
Loading…
Reference in New Issue
Block a user