johnhamelink
3/26/2015 - 4:32 PM

custom-session.js

import Ember from 'ember';
import Session from 'simple-auth/session';

export default {
  name: 'custom-session',
  before: 'simple-auth',
  initialize: function(container){
    Session.reopen({
      setCurrentUser: function() {
        var id = this.get('user_id');
        var self = this;

        if (!Ember.isEmpty(id)) {
          return container.lookup('store:main').find('user', 'me').then(function(user){
            self.set('currentUser', user);
          });
        }
      }.observes('user_id')
    });
  }
};