Skip to content

Instantly share code, notes, and snippets.

@yurifrl
Created November 11, 2015 18:06
Show Gist options
  • Save yurifrl/ac3bd7f7eee237c1a932 to your computer and use it in GitHub Desktop.
Save yurifrl/ac3bd7f7eee237c1a932 to your computer and use it in GitHub Desktop.
attempt of add current user to session
//packages/auth/app/initializers/addon-ember-auth-setup-session.js
import addonSession from 'addon-ember-auth/services/session';
export function initialize(app) {
app.register('custom:session', yeboSession);
/* Inject the Session Service into Routes & Components */
app.inject('route', 'session', 'custom:session');
app.inject('controller', 'session', 'custom:session');
app.inject('component', 'session', 'custom:session');
}
export default {
name: 'addon-ember-auth-setup-session',
after: 'ember-simple-auth',
initialize: initialize
};
// index.hbs
{{!doesnt work}}
{{session.currentUser}}
// packages/auth/addon/services/session.js
// as here http://log.simplabs.com/
import Ember from 'ember';
import DS from 'ember-data';
import SessionService from 'ember-simple-auth/services/session';
export default SessionService.extend({
currentUser: {},
store: Ember.inject.service(),
account: Ember.computed('data.authenticated.account_id', function() {
const accountId = this.get('data.authenticated.account_id');
if (!Ember.isEmpty(accountId)) {
return DS.PromiseObject.create({
promise: this.get('store').find('account', accountId)
});
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment