Setup authorizer and custom session for account

This commit is contained in:
Matthew Ryan Dillon 2015-10-20 15:04:14 -07:00
parent 30b1706868
commit 52979ac9e2
3 changed files with 29 additions and 1 deletions

View file

@ -0,0 +1,22 @@
import Ember from 'ember';
import DS from 'ember-data';
import parseBase64 from '../utils/parse-base64';
const { service } = Ember.inject;
export default Ember.Service.extend({
session: service('session'),
store: service(),
account: Ember.computed('session.data.authenticated.access_token', function() {
const token = this.get('session.data.authenticated.access_token');
const claims = parseBase64(token);
const id = claims['sub'];
if (!Ember.isEmpty(id)) {
return DS.PromiseObject.create({
promise: this.get('store').findRecord('user', id),
});
}
})
});