project/app/services/session-account.js
Martin Donnelly e06e53e5bd whats wrong?
2016-04-06 16:53:06 +01:00

25 lines
586 B
JavaScript

import Ember from 'ember';
const { inject: { service }, RSVP } = Ember;
export default Ember.Service.extend({
session: service('session'),
store: service(),
loadCurrentUser() {
return new RSVP.Promise((resolve, reject) => {
const accountId = this.get('session.data.authenticated.account_id');
if (!Ember.isEmpty(accountId)) {
return this.get('store').find('account', accountId).then((account) => {
this.set('account', account);
return resolve();
}, reject);
} else {
return resolve();
}
});
}
});