diff --git a/demo-shell-ng2/app/app.component.ts b/demo-shell-ng2/app/app.component.ts index 2f89a4f6da..ad1a1365aa 100644 --- a/demo-shell-ng2/app/app.component.ts +++ b/demo-shell-ng2/app/app.component.ts @@ -51,11 +51,18 @@ export class AppComponent { } isLoggedIn(): boolean { + this.redirectToLoginPageIfNotLoggedIn(); return this.auth.isLoggedIn(); } + redirectToLoginPageIfNotLoggedIn(): void { + if (!this.isLoginPage() && !this.auth.isLoggedIn()) { + this.router.navigate(['/login']); + } + } + isLoginPage(): boolean { - return location.pathname === '/login' || location.pathname === '/'; + return location.pathname === '/login' || location.pathname === '/' || location.pathname === '/settings'; } onLogout(event) {