Created
May 29, 2014 16:19
-
-
Save jrhe/179defd468eda68d53c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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