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