From ad961f303958de9739af497099696efc6934aad6 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Mon, 24 May 2021 16:28:42 +0200 Subject: [PATCH] Bugfix/fix missing header of public pages (#121) * Fix missing header of public pages * Update changelog --- CHANGELOG.md | 1 + apps/client/src/app/core/auth.guard.ts | 9 ++++++--- .../src/app/pages/about/about-page-routing.module.ts | 5 ++++- .../src/app/pages/pricing/pricing-page-routing.module.ts | 5 ++++- .../app/pages/resources/resources-page-routing.module.ts | 5 ++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 174ea202e..f0cd5aa85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed the performance chart by considering the investment +- Fixed missing header of public pages (_About_, _Pricing_, _Resources_) ## 1.7.0 - 22.05.2021 diff --git a/apps/client/src/app/core/auth.guard.ts b/apps/client/src/app/core/auth.guard.ts index 12e948566..fcd5fe047 100644 --- a/apps/client/src/app/core/auth.guard.ts +++ b/apps/client/src/app/core/auth.guard.ts @@ -9,14 +9,14 @@ import { ViewMode } from '@prisma/client'; import { EMPTY } from 'rxjs'; import { catchError } from 'rxjs/operators'; -import { DataService } from '../services/data.service'; import { SettingsStorageService } from '../services/settings-storage.service'; import { UserService } from '../services/user/user.service'; @Injectable({ providedIn: 'root' }) export class AuthGuard implements CanActivate { + private static PUBLIC_PAGE_ROUTES = ['/about', '/pricing', '/resources']; + constructor( - private dataService: DataService, private router: Router, private settingsStorageService: SettingsStorageService, private userService: UserService @@ -35,7 +35,10 @@ export class AuthGuard implements CanActivate { .get() .pipe( catchError(() => { - if (state.url !== '/start') { + if (AuthGuard.PUBLIC_PAGE_ROUTES.includes(state.url)) { + resolve(true); + return EMPTY; + } else if (state.url !== '/start') { this.router.navigate(['/start']); resolve(false); return EMPTY; diff --git a/apps/client/src/app/pages/about/about-page-routing.module.ts b/apps/client/src/app/pages/about/about-page-routing.module.ts index 514061101..38e89077c 100644 --- a/apps/client/src/app/pages/about/about-page-routing.module.ts +++ b/apps/client/src/app/pages/about/about-page-routing.module.ts @@ -1,9 +1,12 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; import { AboutPageComponent } from './about-page.component'; -const routes: Routes = [{ path: '', component: AboutPageComponent }]; +const routes: Routes = [ + { path: '', component: AboutPageComponent, canActivate: [AuthGuard] } +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/apps/client/src/app/pages/pricing/pricing-page-routing.module.ts b/apps/client/src/app/pages/pricing/pricing-page-routing.module.ts index bc40ef275..183dbed0e 100644 --- a/apps/client/src/app/pages/pricing/pricing-page-routing.module.ts +++ b/apps/client/src/app/pages/pricing/pricing-page-routing.module.ts @@ -1,9 +1,12 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; import { PricingPageComponent } from './pricing-page.component'; -const routes: Routes = [{ path: '', component: PricingPageComponent }]; +const routes: Routes = [ + { path: '', component: PricingPageComponent, canActivate: [AuthGuard] } +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/apps/client/src/app/pages/resources/resources-page-routing.module.ts b/apps/client/src/app/pages/resources/resources-page-routing.module.ts index 7b6a6d055..74b0502e9 100644 --- a/apps/client/src/app/pages/resources/resources-page-routing.module.ts +++ b/apps/client/src/app/pages/resources/resources-page-routing.module.ts @@ -1,9 +1,12 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { AuthGuard } from '@ghostfolio/client/core/auth.guard'; import { ResourcesPageComponent } from './resources-page.component'; -const routes: Routes = [{ path: '', component: ResourcesPageComponent }]; +const routes: Routes = [ + { path: '', component: ResourcesPageComponent, canActivate: [AuthGuard] } +]; @NgModule({ imports: [RouterModule.forChild(routes)],