diff --git a/src/app/app.component.html b/src/app/app.component.html index b8ca6190b5fae230a0f000e0b02d0178a48eac68..5cb5a697ec2b2a9b5557c8501d0ae9ddcf784ccc 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,6 +1,6 @@ <ion-app> <ion-split-pane contentId="main-content"> - <ion-menu contentId="main-content" type="overlay" *ngIf="restService.isUserLoggedIn"> + <ion-menu contentId="main-content" type="overlay" *ngIf="restService.isUserLoggedIn && !restService.isLoginPage"> <ion-header> <ion-toolbar> <ion-title>Menu</ion-title> diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 275e9773c38bd9ffe54294ded84e3b31cfe41243..69934437a4b088d4bb7eabfeac3ac0922fa06e7a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -15,7 +15,7 @@ import { RestService } from './rest.service'; }) export class AppComponent { - + isLoginPage = false; public appPages = [ { @@ -36,9 +36,16 @@ export class AppComponent { private statusBar: StatusBar, public restService: RestService, private storage: Storage, - private router: Router - ) { + private router: Router) { + this.initializeApp(); + + let href = window.location.pathname + if(href === "/login") { + this.restService.isLoginPage = true; + } else { + this.restService.isLoginPage = false; + } this.storage.get('token').then((token) => { if(token === "") { this.router.navigateByUrl('/login'); diff --git a/src/app/auth/login/login.page.ts b/src/app/auth/login/login.page.ts index 5f20f0473bd60546a91d16e0aef75fbf184189f1..863bec57b03222d71c2afffb68bb4424e6928ad0 100644 --- a/src/app/auth/login/login.page.ts +++ b/src/app/auth/login/login.page.ts @@ -38,6 +38,7 @@ export class LoginPage implements OnInit { .subscribe((data) => { console.log('my data: ', data); this.restService.setToken(data.token); + this.restService.isLoginPage = false; this.router.navigateByUrl('/home'); }, (error) => { console.log(error); diff --git a/src/app/rest.service.ts b/src/app/rest.service.ts index e6e4ac6214b6a8a9e423d2ac835980f9a8069930..aadef85b5a4c06e3635e219c7364e490cfc624de 100644 --- a/src/app/rest.service.ts +++ b/src/app/rest.service.ts @@ -7,6 +7,7 @@ import { Storage } from '@ionic/storage'; export class RestService { public isUserLoggedIn = false; + public isLoginPage = false; constructor(private storage: Storage) { }