title: How to persist current logged in user details across page reload in EmberJS?
body: <p>I use <code>ember-simple-auth</code> to manage authentication in my ember app.</p>
  
  <p>The addon provides a <code>session</code> library which apparently stores the response from API server when I login using token authentication. The response contains typical oAuth2 response like access token, refresh token, expiry time etc. The library provides a boolean variable which tells if the user is authenticated or not currently.</p>
  
  <p>I use an instance initializer which uses this boolean variable to fetch and store current user details. The code looks like this:</p>
  
  <pre><code>// app/instance-initializers/current-user.js
  import Session from "ember-simple-auth/services/session";
  export default {
    name: "current-user",
    before: "ember-simple-auth",
    initialize: function(container) {
      Session.reopen({
        setCurrentUser: function() {
          if (this.get('isAuthenticated')) {
            container.lookup("service:store").find('user', 'me').then((user) =&gt; {
              this.set('currentUser', user);
            });
          }
        }.observes('isAuthenticated')
      });
    }
  };
  </code></pre>
  
  <p>This works fine when I login and navigate across different routes in the app. The problem comes when I reload some page. The current user details somehow get erased and this <code>setCurrentUser</code> is also called but it gets called after all the hooks in the current route are called. So in hooks like <code>model</code>, <code>beforeModel</code>, <code>setupController</code> etc. <code>session.currentUser</code> is not set and it is set only after all these hooks are called.</p>
  
  <p>How to avoid this? How to make the current user details available in route hooks on page reload?</p>