redirect to login page not loggedin users

This commit is contained in:
Mario Romano
2016-11-02 09:51:49 +00:00
parent e5dc17ab2c
commit 3877cd60b2
+8 -1
View File
@@ -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) {