Created
June 21, 2015 23:34
-
-
Save mszoernyi/9f699a11a979a36d9e05 to your computer and use it in GitHub Desktop.
User object/currentUser as custom session
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 Session from 'simple-auth/session'` | |
class CustomSession extends Session | |
#_store: Ember.inject.service("store") | |
# inject.service(store) lands in ember data 1.13 | |
_store: ~> @container.lookup('store:main') | |
# TODO with simple-auth 0.8+ the returned api data is stored under secure! so secure.user_id will be the new path | |
currentUser: Ember.computed 'user_id', 'isAuthenticated', -> | |
userId = @user_id | |
logger @, 'loading user', userId | |
if userId && @isAuthenticated | |
return @_store.find('user', userId) | |
#DS.PromiseObject.create | |
#promise: @_store.find('user', userId) | |
`export default CustomSession` |
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
ENV['simple-auth'] = { | |
session: 'custom' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment