title: Ember Simple Auth - injecting current user into every route
body: <p>I am building a site using Ember Simple Auth.</p>
  
  <p>I followed <a href="http://blog.willrax.com/fetching-the-current-user-with-simple-auth/">these instructions</a> to try and add the current user object to the session and it worked, using this slightly adapted code:</p>
  
  <pre><code>import Ember from 'ember';
  import Session from 'simple-auth/session';
  
  export default {
    name: "current-user",
    before: "simple-auth",
    initialize: function(container) {
      Session.reopen({
        setCurrentUser: function() {
          var accessToken = this.get('secure.token');
          var _this = this;
          if (!Ember.isEmpty(accessToken)) {
            return container.lookup('store:main').find('user', 'me').then(function(user) {
              _this.set('content.currentUser', user);
            });
          }
        }.observes('secure.token'),
        setAccount: function() {
          var _this = this;
          return container.lookup('store:main').find('account', this.get('content.currentUser.account.content.id')).then(function(account) {
            _this.set('content.account', account);
          });
        }.observes('content.currentUser'),
      });
    }
  };
  </code></pre>
  
  <p>However, using the latest version of Ember I'm getting the following:</p>
  
  <blockquote>
    <p>DEPRECATION: <code>lookup</code> was called on a Registry. The <code>initializer</code> API no longer receives a container, and you should use an <code>instanceInitializer</code> to look up objects from the container. See <a href="http://emberjs.com/guides/deprecations#toc_deprecate-access-to-instances-in-initializers">http://emberjs.com/guides/deprecations#toc_deprecate-access-to-instances-in-initializers</a> for more details.</p>
  </blockquote>
  
  <p>I know that I need to split the above into /app/initializers and /app/instance-initializers (as per the notes <a href="http://emberjs.com/deprecations/v1.x/#toc_deprecate-access-to-instances-in-initializers">here</a>) but I'm not quite sure how to go about it.</p>
  
  <p>Of course, if there is an easier/cleaner way to make the user and account objects available to every route/template I'd love to hear them :)</p>
  
  <p>Thanks</p>