So, I'm trying to get started with ionic 2 from ionic 1 and you need to be guided by how to configure authentication in my project. In particular, I use firebase and angularfire2.
As a general approach, I should:
a. Check the / localStorage session on app.ts and set rootPage to log in if it does not authenticate? Using this method, if I log out of the user account and return to the root URL, the tabs appear below.
b. Create the login page as modal, which removes the problem with the tabs appearing below, but I'm not sure that I have to fire the modal from app.ts, since I'm not sure if the application has root mode, I have to link.
In addition, should I configure authorization and logout as a service and reorganize it, and not have it on the login page and the logout button in the profile controllers?
Here is my logic using method A:
app.ts
export class MyApp { rootPage: any; local: Storage = new Storage(LocalStorage); constructor(platform: Platform) { this.local.get('user').then(user => { if (user) { this.rootPage = TabsPage; } else { this.rootPage = LoginPage; } }); platform.ready().then(() => { StatusBar.styleDefault(); }); } }
And in myProfile.ts
logout() { this.local.remove('user'); this.user = null; let modal = Modal.create(LoginPage); this.nav.present(modal);
source share