From f14316daf7a461613e1a1b12e2fbb21e4612ec62 Mon Sep 17 00:00:00 2001 From: David Donges <david.donges@mni.thm.de> Date: Tue, 6 Mar 2018 14:52:50 +0100 Subject: [PATCH] Display notification on forbidden page request --- src/app/authentication.guard.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/authentication.guard.ts b/src/app/authentication.guard.ts index c4cf7fe48..603935c92 100644 --- a/src/app/authentication.guard.ts +++ b/src/app/authentication.guard.ts @@ -5,10 +5,12 @@ import { AuthenticationService } from './authentication.service'; import 'rxjs/add/operator/map'; import 'rxjs/add/observable/of'; import 'rxjs/add/operator/catch'; +import { NotificationService } from './notification.service'; @Injectable() export class AuthenticationGuard implements CanActivate { constructor(private authenticationService: AuthenticationService, + private notificationService: NotificationService, private router: Router) { } @@ -16,6 +18,7 @@ export class AuthenticationGuard implements CanActivate { state: RouterStateSnapshot): Observable<boolean> { return this.authenticationService.isLoggedIn().map(isLoggedIn => { if (!isLoggedIn) { + this.notificationService.show(`You're not authorized to view this page.`); // TODO: redirect to error page this.router.navigate(['/']); } -- GitLab