This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
hymenobacterdotinfo/app/services/session-account.js
2015-11-06 11:20:28 -07:00

23 lines
649 B
JavaScript

import Ember from 'ember';
import DS from 'ember-data';
import parseBase64 from '../utils/parse-base64';
const { Service, computed, isEmpty, inject: { service } } = Ember;
const { PromiseObject } = DS;
export default Service.extend({
session: service('session'),
store: service(),
account: 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 (!isEmpty(id)) {
return PromiseObject.create({
promise: this.get('store').findRecord('user', id),
});
}
})
});