Reputation: 133
I can't seem to find a direct answer that deals with a code example of how it works but I'm using simple-auth 0.7.3
. with ember-cli
and simple-auth-devise
.
I can authenticate just fine but once I refresh the page session is killed. I saw a previous post and the guy didn't have the right object but what about a case when the object is correct?
{"authenticator":"simple-auth-authenticator:devise","user_id":53,"user_token":"Vm2TwefZCwaAo8hfg&pT","user_email":"[email protected]"}
Im not the sharpest knife in the draw but I'm hoping someone can shed some light on why a session is killed and how/where to prevent it.
Upvotes: 0
Views: 164
Reputation: 133
Based on the what is being put in the localstorage:
{"authenticator":"simple-auth-authenticator:devise","user_id":53,"user_token":"Vm2TwefZCwaAo8hfg&pT","user_email":"[email protected]"}
Ember simple auth is using "user" as a resourceName in the config: Ember Simple Auth Devise
The resourceName is normally added when the server endpoint is expecting more than email,password. In this case the endpoint expects user_email,user_password.
And by default When you refresh a page simple auth checks the localstorage for email,token. You have to also change that to user_email, user_token.
in the Config:
ENV['simple-auth-devise'] = {
authorizer: 'simple-auth-authorizer:devise',
serverTokenEndpoint: ENV.APP.HOST+'/' + ENV.NAMESPACE +'/users/sign_in',
resourceName: 'user',
tokenAttributeName: 'user_token',
identificationAttributeName: 'user_email'};
And that resolves the persistence issue.
Upvotes: 2