Skip to content

Instantly share code, notes, and snippets.

@mszoernyi
Created June 21, 2015 23:34
Show Gist options
  • Save mszoernyi/9f699a11a979a36d9e05 to your computer and use it in GitHub Desktop.
Save mszoernyi/9f699a11a979a36d9e05 to your computer and use it in GitHub Desktop.
User object/currentUser as custom session
`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`
ENV['simple-auth'] = {
session: 'custom'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment