From 9b0250d4fd344efda56ef33e9bc6147cfb7efe7f Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:06:02 -0700 Subject: [PATCH] Check undefined data properties before i18n (#9590) * remove duplicate route * check for undefined before translation --- apps/web/src/app/oss-routing.module.ts | 19 ------------------ .../anon-layout-wrapper.component.ts | 20 +++++++++++++++---- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/apps/web/src/app/oss-routing.module.ts b/apps/web/src/app/oss-routing.module.ts index 44cfc10873..209a291a71 100644 --- a/apps/web/src/app/oss-routing.module.ts +++ b/apps/web/src/app/oss-routing.module.ts @@ -238,25 +238,6 @@ const routes: Routes = [ }, ], }, - { - path: "recover-2fa", - canActivate: [unauthGuardFn()], - children: [ - { - path: "", - component: RecoverTwoFactorComponent, - }, - { - path: "", - component: EnvironmentSelectorComponent, - outlet: "environment-selector", - }, - ], - data: { - pageTitle: "recoverAccountTwoStep", - titleId: "recoverAccountTwoStep", - } satisfies DataProperties & AnonLayoutWrapperData, - }, { path: "remove-password", component: RemovePasswordComponent, diff --git a/libs/auth/src/angular/anon-layout/anon-layout-wrapper.component.ts b/libs/auth/src/angular/anon-layout/anon-layout-wrapper.component.ts index 5efd2cf9ab..e4472c368f 100644 --- a/libs/auth/src/angular/anon-layout/anon-layout-wrapper.component.ts +++ b/libs/auth/src/angular/anon-layout/anon-layout-wrapper.component.ts @@ -27,9 +27,21 @@ export class AnonLayoutWrapperComponent { private route: ActivatedRoute, private i18nService: I18nService, ) { - this.pageTitle = this.i18nService.t(this.route.snapshot.firstChild.data["pageTitle"]); - this.pageSubtitle = this.i18nService.t(this.route.snapshot.firstChild.data["pageSubtitle"]); - this.pageIcon = this.route.snapshot.firstChild.data["pageIcon"]; - this.showReadonlyHostname = this.route.snapshot.firstChild.data["showReadonlyHostname"]; + const routeData = this.route.snapshot.firstChild?.data; + + if (!routeData) { + return; + } + + if (routeData["pageTitle"] !== undefined) { + this.pageTitle = this.i18nService.t(routeData["pageTitle"]); + } + + if (routeData["pageSubtitle"] !== undefined) { + this.pageSubtitle = this.i18nService.t(routeData["pageSubtitle"]); + } + + this.pageIcon = routeData["pageIcon"]; + this.showReadonlyHostname = routeData["showReadonlyHostname"]; } }