roughing in custom session (again :( )
This commit is contained in:
parent
bb2386807c
commit
72c957f8dc
7 changed files with 42 additions and 10 deletions
24
app/initializers/custom-session.js
Normal file
24
app/initializers/custom-session.js
Normal 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
|
||||
};
|
Reference in a new issue