Hi,
I am writing some data to the session and it ends up lost after refreshing the page, or opening another tab.
To reproduce this:
this.set('session.X', 'Y');
This code correctly alters the localStorage, but after a page refresh all is lost.
Is this when the session is authenticated? Please post the complete session content in localStorage here. Also which version of Ember Simple Auth are you using?
I am using the latest ember-simple-auth and I'm doing authentication with torii's "facebook-connect". So basically localStorage is populated by torii.
After refreshing the page the session is still authenticated, but I lose the things I've added manually using the instruction of my previous comment.
What's the actual content of localSorage before and after the reload?
before the reload, localStorage has
{
"secure":{
"authenticator":"simple-auth-authenticator:torii",
"userId":"...",
"accessToken":"...",
"provider":"facebook-connect"
},
"X":"Y"
}
after reload:
{
"secure":{
"authenticator":"simple-auth-authenticator:torii",
"userId":"...",
"accessToken":"...",
"provider":"facebook-connect"
}
}
This should actually be working with 0.8.0-beta.1.
sorry I made a mistake. accessToken and userId are wiped too,
so before refresh:
{
"secure":{
"authenticator":"simple-auth-authenticator:torii",
"userId":"...",
"accessToken":"...",
"provider":"facebook-connect"
},
"X":"Y"
}
and after refresh
{
"secure":{
"authenticator":"simple-auth-authenticator:torii",
"provider":"facebook-connect"
}
}
session.isAuthenticated still evaluates to true though.
Hm, looks like the provider's fetch method doesn't resolve with the correct data (see invocation here). Probably the Ember Simple Auth code is wrong anyway as it shouldn't actually require the provider to resolve with the session data - will change that in the next 0.8.0 beta.
I am getting the same issue but i am not using the torii library.
Here is what i did:
Here is what happens
this.get('session').set('locale,'en-us');locale: 'en-us' property. locale:'en-us' property is now missing. For me anything i had present in the secure section of session was restored. Everything else went missing.
EDIT:
Looks like on session.restore() it restores the data from the store but then only sets the content.secure property back.
return new Ember.RSVP.Promise(function(resolve, reject) {
var restoredContent = _this.store.restore();
var authenticator = (restoredContent.secure || {}).authenticator;
if (!!authenticator) {
delete restoredContent.secure.authenticator;
_this.container.lookup(authenticator).restore(restoredContent.secure).then(function(content) {
_this.setup(authenticator, content);
resolve();
Right, that's a bug - PR would be great!
Guys, I am using 0.8.0 and I still have the issue.
I must add that the session is not authenticated
Local storage is
{"secure":{}}
In a controller action, I do
this.set('session.foo', 'bar');
Local storage value is then
{"secure":{},"foo":"bar"}
I reload the page and get the following local storage
{"secure":{}}
I'll try with an authenticated session to see if it behaves differently
Having same issue.
NVM. I am using devise authenticator and I was returning an invalid token key from server.
I had the same problem using jj-abrams branch,
I fixed with
ENV['ember-simple-auth'] = {
base: {
store: 'session-store:local-storage'
}
...
@alejandrogutierrez 's comment made me double check what authenticator we were using and I realized it was a custom one that failed to implement the restore method correctly.
Sorry for the noise
This is happening for me with ember-2.2.0 and ember-simple-auth-1.0.0. I'm using a OAuth2PasswordGrant and no special configuration. The localStorage before and after reload are the same:
{
"ember_simple_auth:session":"{\"authenticated\":{\"authenticator\":\"authenticator:oauth2\",\"access_token\":\"XXX\",\"token_type\":\"bearer\",\"expires_in\":7200,\"refresh_token\":\"YYY\",\"created_at\":1450794201,\"expires_at\":1450801401673}}"
}
I'm calling this.get("session").set("someProperty", "someValue") and as long as I don't refresh, I can retrieve it from the session.
Just in case someone comes here with the same 'problem':
this.get('session').set('test1', 'value1'); // doesn't work
this.get('session').set('data.test2', 'value2'); // works
this.set('session.test3', 'value3'); // doesn't work
this.set('session.data.test4', 'value4'); // doesn't work
Thank you indr. This was precisely my problem too.
Most helpful comment
Just in case someone comes here with the same 'problem':