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