Commit 7fa348ca authored by Ratnadeep Rajendra Kharade's avatar Ratnadeep Rajendra Kharade
Browse files

Removed navigation menu from login page and handled session condition.

parent d38661cb
<ion-app> <ion-app>
<ion-split-pane contentId="main-content"> <ion-split-pane contentId="main-content">
<ion-menu contentId="main-content" type="overlay"> <ion-menu contentId="main-content" type="overlay" *ngIf="restService.isUserLoggedIn">
<ion-header> <ion-header>
<ion-toolbar> <ion-toolbar>
<ion-title>Menu</ion-title> <ion-title>Menu</ion-title>
......
...@@ -3,6 +3,10 @@ import { Component } from '@angular/core'; ...@@ -3,6 +3,10 @@ import { Component } from '@angular/core';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx';
import { Storage } from '@ionic/storage';
import { Router } from '@angular/router';
import { RestService } from './rest.service';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
...@@ -10,6 +14,9 @@ import { StatusBar } from '@ionic-native/status-bar/ngx'; ...@@ -10,6 +14,9 @@ import { StatusBar } from '@ionic-native/status-bar/ngx';
styleUrls: ['app.component.scss'] styleUrls: ['app.component.scss']
}) })
export class AppComponent { export class AppComponent {
public appPages = [ public appPages = [
{ {
title: 'Home', title: 'Home',
...@@ -26,9 +33,19 @@ export class AppComponent { ...@@ -26,9 +33,19 @@ export class AppComponent {
constructor( constructor(
private platform: Platform, private platform: Platform,
private splashScreen: SplashScreen, private splashScreen: SplashScreen,
private statusBar: StatusBar private statusBar: StatusBar,
public restService: RestService,
private storage: Storage,
private router: Router
) { ) {
this.initializeApp(); this.initializeApp();
this.storage.get('token').then((token) => {
if(token === "") {
this.router.navigateByUrl('/login');
} else {
this.restService.isUserLoggedIn = true;
}
});
} }
initializeApp() { initializeApp() {
......
...@@ -46,7 +46,5 @@ export class LoginPage implements OnInit { ...@@ -46,7 +46,5 @@ export class LoginPage implements OnInit {
} }
register() { register() {
this.router.navigateByUrl('/register'); this.router.navigateByUrl('/register');
} }
} }
...@@ -6,11 +6,13 @@ import { Storage } from '@ionic/storage'; ...@@ -6,11 +6,13 @@ import { Storage } from '@ionic/storage';
}) })
export class RestService { export class RestService {
public isUserLoggedIn = false;
constructor(private storage: Storage) { } constructor(private storage: Storage) { }
setToken(token) { setToken(token) {
// set a key/value
this.storage.set('token', token); this.storage.set('token', token);
this.isUserLoggedIn = true;
} }
getToken() { getToken() {
......
Supports Markdown
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