title: How to implement login flow in ionic 2?
body: <p>So I'm trying to get started with ionic 2 from ionic 1 and need some guidance on how to set up authentication in my project.  Specifically I'm using firebase and angularfire2.  </p>
  
  <p>As a general approach should I either:</p>
  
  <p>a. Check for session/localStorage on app.ts and set the rootPage to login if unauthenticated?  Using this method if I log the user out and set the nav rootpage back to the login, the tabs are displayed at the bottom.</p>
  
  <p>b. Create the login page as a modal which removes the problem of the tabs appearing at the bottom, but I'm not sure if I should be firing the modal from app.ts since I'm not sure if the application itself has a root view I should be referencing.</p>
  
  <p>Also, should I set up the auth login and logout as a service and refactor it out rather than having it in the login page and the logout button in the profile controllers?</p>
  
  <p>Here's my logic thus far using method A:</p>
  
  <p>app.ts</p>
  
  <pre><code>export class MyApp {
    rootPage: any;
    local: Storage = new Storage(LocalStorage);
    constructor(platform: Platform) {
      this.local.get('user').then(user =&gt; {
        if (user) {
          this.rootPage = TabsPage;
        } else {
          this.rootPage = LoginPage;
        }
      });
  
      platform.ready().then(() =&gt; {
        StatusBar.styleDefault();
      });
    }
  }
  </code></pre>
  
  <p>And in myProfile.ts</p>
  
  <pre><code>  logout() {
      this.local.remove('user');
      this.user = null;
      let modal = Modal.create(LoginPage);
      this.nav.present(modal); //should I set the rootPage instead?  if so how do I remove the tabBar or set the rootpage of the containing app root page
    }
  </code></pre>