Commit a6f47bee authored by Ratnadeep Rajendra Kharade's avatar Ratnadeep Rajendra Kharade
Browse files

Fixed bug on login page.

parent db76e59f
<ion-app> <ion-app>
<ion-split-pane contentId="main-content"> <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-header>
<ion-toolbar> <ion-toolbar>
<ion-title>Menu</ion-title> <ion-title>Menu</ion-title>
......
...@@ -15,7 +15,7 @@ import { RestService } from './rest.service'; ...@@ -15,7 +15,7 @@ import { RestService } from './rest.service';
}) })
export class AppComponent { export class AppComponent {
isLoginPage = false;
public appPages = [ public appPages = [
{ {
...@@ -36,9 +36,16 @@ export class AppComponent { ...@@ -36,9 +36,16 @@ export class AppComponent {
private statusBar: StatusBar, private statusBar: StatusBar,
public restService: RestService, public restService: RestService,
private storage: Storage, private storage: Storage,
private router: Router private router: Router) {
) {
this.initializeApp(); 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) => { this.storage.get('token').then((token) => {
if(token === "") { if(token === "") {
this.router.navigateByUrl('/login'); this.router.navigateByUrl('/login');
......
...@@ -38,6 +38,7 @@ export class LoginPage implements OnInit { ...@@ -38,6 +38,7 @@ export class LoginPage implements OnInit {
.subscribe((data) => { .subscribe((data) => {
console.log('my data: ', data); console.log('my data: ', data);
this.restService.setToken(data.token); this.restService.setToken(data.token);
this.restService.isLoginPage = false;
this.router.navigateByUrl('/home'); this.router.navigateByUrl('/home');
}, (error) => { }, (error) => {
console.log(error); console.log(error);
......
...@@ -7,6 +7,7 @@ import { Storage } from '@ionic/storage'; ...@@ -7,6 +7,7 @@ import { Storage } from '@ionic/storage';
export class RestService { export class RestService {
public isUserLoggedIn = false; public isUserLoggedIn = false;
public isLoginPage = false;
constructor(private storage: Storage) { } constructor(private storage: Storage) { }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment