从this question开始,我尝试在自定义会话中设置currentUser和帐户属性:
/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);
})
})
});
但由于某种原因,永远不会调用console.log('account');
。我想这是因为currentUser是一个承诺,因此还没有解决?
我应该返回Ember.RSVP.hash吗?