roughing in custom session (again :( )

This commit is contained in:
Matthew Dillon 2015-07-09 20:52:01 -08:00
parent bb2386807c
commit 72c957f8dc
7 changed files with 42 additions and 10 deletions

View file

@ -0,0 +1,24 @@
import Session from 'simple-auth/session';
import parseBase64 from '../utils/parse-base64';
var CustomSession = Session.extend({
currentUser: function() {
let token = this.get('secure.token');
if (!Ember.isEmpty(token)) {
let t = parseBase64(token);
return this.container.lookup('store:main').find('user', t['sub']);
}
return null;
}.property('secure.token'),
});
export function initialize(container, application) {
application.register('session:custom', CustomSession);
}
export default {
name: 'custom-session',
before: 'simple-auth',
initialize: initialize
};