Created
November 11, 2015 18:06
-
-
Save yurifrl/ac3bd7f7eee237c1a932 to your computer and use it in GitHub Desktop.
attempt of add current user to session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.hbs | |
{{!doesnt work}} | |
{{session.currentUser}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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