Ember Simple Auth - setting multiple properties in a custom session

192 Views Asked by At

Following on from this question I am trying to set both the currentUser and the account properties in my custom session:

/app/sessions/custom.js

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

export default Session.extend({
  currentUser: Ember.computed('secure.user_id', 'isAuthenticated', function() {
    console.log('currentUser');
    var userId = this.get('secure.user_id');
    if (userId && this.get('isAuthenticated')) {
      return this._store.find('user', userId);
    }
  }),
  account: Ember.computed('currentUser', function() {
    console.log('account');
    this.get('currentUser').then(function(currentUser) {
      return this._store.find('account', currentUser.get('account').id);
    })
  })
});

but for some reason the console.log('account'); is never called. I guess that this is because currentUser is a promise and thus hasn't yet resolved?

Should I return an Ember.RSVP.hash instead?

0

There are 0 best solutions below