Following this SO answer, I'm trying to get the Ember Simple Auth session with container.lookup('simple-auth-session:main');
but this gives me undefined.
I'm using Ember Cli and the Ember Simple Auth Devise authenticator.
Following this SO answer, I'm trying to get the Ember Simple Auth session with container.lookup('simple-auth-session:main');
but this gives me undefined.
I'm using Ember Cli and the Ember Simple Auth Devise authenticator.
@marcoow's comment above worked like a charm. He pointed me to this example
FIRST: add an initializer registering the custom session
Ember.Application.initializer(
name: 'authentication'
before: 'simple-auth'
initialize: (container, application) ->
container.register('session:custom', App.CustomSession)
)
SECOND: replace the session with your custom session
window.ENV['simple-auth'] = {
session: 'session:custom'
}
THIRD: define the custom session
App.CustomSession = SimpleAuth.Session.extends(
currentUser: (->
unless Ember.isEmpty(@user_id)
@container.lookup('session:main').load('user', @user_id)
//Note! I'm using Ember Persistence Foundation, therefore 'session:main',
//but if you're using Ember Data, use 'store:main'
).property('user_id')
)
'simple-auth'
initializer? If not the session won't be already registered. – marcoowafter: authentication
toafter: 'simple-auth-devise'
, which I think is correct. – niftygriftycurrentUser
property somehow I'd suggest you follow this Ember Simple Auth example: github.com/simplabs/ember-simple-auth/blob/master/examples/… – marcoowsession.user
. – marcoow