Skip to content

Instantly share code, notes, and snippets.

@jrhe
Created May 29, 2014 16:19
Show Gist options
  • Save jrhe/179defd468eda68d53c6 to your computer and use it in GitHub Desktop.
Save jrhe/179defd468eda68d53c6 to your computer and use it in GitHub Desktop.
import DeviseAPIAuthenticator from 'devon-discovery/authenticators/devise_api';
export default {
name: 'authentication',
initialize: function(container, application) {
container.register('ember-simple-auth-authenticator:devise_api', DeviseAPIAuthenticator);
// customize the session so that it allows access to the account object
Ember.SimpleAuth.Session.reopen({
user: function() {
var userId = this.get('user_id');
if (!Ember.isEmpty(userId)) {
return container.lookup('store:main').find('user', userId);
}
}.property('userId')
});
Ember.SimpleAuth.setup(container, application, {
authorizerFactory: 'ember-simple-auth-authorizer:devise'
});
var session = container.lookup('ember-simple-auth-session:main');
container.register('user:current', session.get('user'), {instantiate: false});
container.injection('controller', 'currentUser', 'user:current');
container.injection('route', 'currentUser', 'user:current');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment