Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { Platform } from 'ionic-angular';
- import { StatusBar } from '@ionic-native/status-bar';
- import { SplashScreen } from '@ionic-native/splash-screen';
- import { tokenNotExpired } from 'angular2-jwt';
- import {Login} from "../pages/login/login";
- import {HomePage} from "../pages/home/home";
- import {Storage} from "@ionic/storage";
- import {Costumize} from "../pages/costumize/costumize";
- @Component({
- templateUrl: 'app.html'
- })
- export class MyApp {
- rootPage:any;
- constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, storage: Storage) {
- platform.ready().then(() => {
- // Okay, so the platform is ready and our plugins are available.
- // Here you can do any higher level native things you might need.
- statusBar.styleDefault();
- splashScreen.hide();
- storage.get('id_token').then(token => {
- if(tokenNotExpired('id_token', token)) {
- storage.get('costumized').then(result => {
- if(result) {
- this.rootPage = HomePage;
- } else {
- this.rootPage = Costumize;
- }
- }).catch(e => {
- this.rootPage = Login
- });
- } else {
- this.rootPage = Login;
- }
- });
- });
- }
- }
Add Comment
Please, Sign In to add comment