From 234a832fc445e43d799989a93bbd78428542f06e Mon Sep 17 00:00:00 2001 From: Alec Rippberger <127791530+alec-livefront@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:45:00 -0600 Subject: [PATCH] /register does not redirect to /signup when email-verification flag is enabled (#12001) * Manually route to signup page when the email verification feature flag is enabled * Revert "Manually route to signup page when the email verification feature flag is enabled" This reverts commit f3a2b412b948cf47f86739df41acad851c6c2ff4. * Do not show toast when redirecting to signup --- apps/web/src/app/oss-routing.module.ts | 2 +- .../src/platform/guard/feature-flag.guard.ts | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/web/src/app/oss-routing.module.ts b/apps/web/src/app/oss-routing.module.ts index 614401e870..20361c7edc 100644 --- a/apps/web/src/app/oss-routing.module.ts +++ b/apps/web/src/app/oss-routing.module.ts @@ -112,7 +112,7 @@ const routes: Routes = [ path: "register", component: TrialInitiationComponent, canActivate: [ - canAccessFeature(FeatureFlag.EmailVerification, false, "/signup"), + canAccessFeature(FeatureFlag.EmailVerification, false, "/signup", false), unauthGuardFn(), ], data: { titleId: "createAccount" } satisfies RouteDataProperties, diff --git a/libs/angular/src/platform/guard/feature-flag.guard.ts b/libs/angular/src/platform/guard/feature-flag.guard.ts index 1f82d810e3..65a29e4d8d 100644 --- a/libs/angular/src/platform/guard/feature-flag.guard.ts +++ b/libs/angular/src/platform/guard/feature-flag.guard.ts @@ -16,11 +16,13 @@ type FlagValue = boolean | number | string; * @param featureFlag - The feature flag to check * @param requiredFlagValue - Optional value to the feature flag must be equal to, defaults to true * @param redirectUrlOnDisabled - Optional url to redirect to if the feature flag is disabled + * @param showToast - Optional boolean to show a toast if the feature flag is disabled - defaults to true */ export const canAccessFeature = ( featureFlag: FeatureFlag, requiredFlagValue: FlagValue = true, redirectUrlOnDisabled?: string, + showToast = true, ): CanActivateFn => { return async () => { const configService = inject(ConfigService); @@ -36,11 +38,13 @@ export const canAccessFeature = ( return true; } - toastService.showToast({ - variant: "error", - title: null, - message: i18nService.t("accessDenied"), - }); + if (showToast) { + toastService.showToast({ + variant: "error", + title: null, + message: i18nService.t("accessDenied"), + }); + } if (redirectUrlOnDisabled != null) { return router.createUrlTree([redirectUrlOnDisabled]);