Skip to content

Commit

Permalink
/register does not redirect to /signup when email-verification flag i…
Browse files Browse the repository at this point in the history
…s 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 f3a2b41.

* Do not show toast when redirecting to signup
  • Loading branch information
alec-livefront authored Nov 20, 2024
1 parent e073c47 commit 234a832
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/app/oss-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 9 additions & 5 deletions libs/angular/src/platform/guard/feature-flag.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]);
Expand Down

0 comments on commit 234a832

Please sign in to comment.