@newelement wrote:
Greetings gals and guys. I'm trying to figure out the best way to globally check for authenticated user. Here's my app.js and auth provider files. Looking for help/feedback on best way to do this:
app.js
import 'es6-shim'; import {App, Platform} from 'ionic-angular'; import {StatusBar} from 'ionic-native'; import {Page1} from './pages/page1/page1'; import {LoginPage} from './pages/login/login'; import {AuthService} from './providers/auth-service/auth-service'; @App({ template: '<ion-nav [root]="rootPage"></ion-nav>', config: {}, providers: [AuthService] }) export class MyApp { static get parameters() { return [[Platform], [AuthService]]; } constructor(platform, auth) { if( !auth.login() ){ this.rootPage = LoginPage; } else { this.rootPage = Page1; } platform.ready().then(() => { StatusBar.styleDefault(); }); } }auth-service.js
import 'es6-shim'; import {App, Platform} from 'ionic-angular'; import {StatusBar} from 'ionic-native'; import {Page1} from './pages/page1/page1'; import {LoginPage} from './pages/login/login'; import {AuthService} from './providers/auth-service/auth-service'; @App({ template: '<ion-nav [root]="rootPage"></ion-nav>', config: {}, providers: [AuthService] }) export class MyApp { static get parameters() { return [[Platform], [AuthService]]; } constructor(platform, auth) { if( !auth.login() ){ this.rootPage = LoginPage; } else { this.rootPage = Page1; } platform.ready().then(() => { StatusBar.styleDefault(); }); } }
Posts: 5
Participants: 4