From f3a2b412b948cf47f86739df41acad851c6c2ff4 Mon Sep 17 00:00:00 2001 From: Alec Rippberger Date: Thu, 14 Nov 2024 13:05:32 -0600 Subject: [PATCH] Manually route to signup page when the email verification feature flag is enabled --- apps/web/src/app/oss-routing.module.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app/oss-routing.module.ts b/apps/web/src/app/oss-routing.module.ts index b208bb3f8d..bc719df4cd 100644 --- a/apps/web/src/app/oss-routing.module.ts +++ b/apps/web/src/app/oss-routing.module.ts @@ -1,5 +1,5 @@ -import { NgModule } from "@angular/core"; -import { Route, RouterModule, Routes } from "@angular/router"; +import { inject, NgModule } from "@angular/core"; +import { Route, Router, RouterModule, Routes } from "@angular/router"; import { unauthUiRefreshSwap } from "@bitwarden/angular/auth/functions/unauth-ui-refresh-route-swap"; import { @@ -33,6 +33,7 @@ import { VaultIcon, } from "@bitwarden/auth/angular"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { twofactorRefactorSwap } from "../../../../libs/angular/src/utils/two-factor-component-refactor-route-swap"; import { flagEnabled, Flags } from "../utils/flags"; @@ -120,7 +121,17 @@ const routes: Routes = [ path: "register", component: TrialInitiationComponent, canActivate: [ - canAccessFeature(FeatureFlag.EmailVerification, false, "/signup"), + async () => { + const configService = inject(ConfigService); + const router = inject(Router); + + return configService.getFeatureFlag(FeatureFlag.EmailVerification).then((flagValue) => { + if (flagValue === true) { + return router.createUrlTree(["/signup"]); + } + return true; + }); + }, unauthGuardFn(), ], data: { titleId: "createAccount" } satisfies RouteDataProperties,