From c5141414150bade4c5cd63067b5158aeb33b9603 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Mon, 20 May 2024 18:26:03 +0200 Subject: [PATCH] bugfixes --- src/app/app.component.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1a85516..d20d105 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -60,12 +60,16 @@ export class AppComponent { .pipe(filter((event) => event instanceof NavigationEnd)) .subscribe(() => { const urlTree = this.router.parseUrl(this.router.url); + const firstSegment = this.getFirstSegment(urlTree); + const allowedRoutes = ['pw-reset', 'register', 'forgot-pw', 'login']; - if ( - urlTree.root.children['primary']?.segments[0]?.path !== 'pw-reset' - ) { + if (!allowedRoutes.includes(firstSegment)) { this.router.navigate(['/login']); } }); } + + private getFirstSegment(urlTree: any): string { + return urlTree.root.children['primary']?.segments[0]?.path || ''; + } }