-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local storage with multiple tabs #91
Comments
I had this issue and now its fixed in |
Hi, I updated to 1.2, added the "container" to setup and now... it breaks everything. It does not work at all. When I submit the login form, no data is saved to the local storage anymore. I need to resubmit the form two times. Then if I switch to another tab, it simply reset the local storage :/. |
I've fixed a bug in my code, it seems to work now. I'm still leaving this issue open until I can confirm it's resolved :) |
It definitely still don't work. When I open the page in another tab, all the fields from the local storage are deleted, excepting those two: ember_simple_auth:access_token and ember_simple_auth:authenticatorFactory |
Can you share a Gist of how you setup your authentication |
Sure, here is the whole initializer: https://gist.github.com/bakura10/686505e4a63a4df4ff24 |
Have you tried Authenticator = Ember.SimpleAuth.Authenticators.OAuth2.reopen({
serverTokenEndpoint: envObject.env.OAUTH_SERVER_TOKEN_ENDPOINT
}); Update Updated gist — https://gist.github.com/seifsallam/5beac9912c54621ea37c |
No more luck. It's a bit strange, sometimes other variables from local storage are removed, like refresh token, while other stay there, for no reason :/. I'm wondering if the fact that I'm running this on localhost may have any effect? |
Well in my case everything was removed from localstorage, so maybe your case is different than mine. As for localhost, i'm running locally too and there is no problem. |
Strange... Which browser are you testing? Can you test in Chrome? |
Running on localhost shouldn't be a problem in general; there might be a bug wrt syncing more than one tab though. Could you check whether you're seeing the behavior with the examples as well? |
I'm using Chrome too |
So Chrome for me works great. But when I tried it now in Safari its not working :| |
It's really hard to reproduce... I've got different results each time! Sometimes it works, sometimes the other tab completely reset the whole local storage, sometimes it only clear one or two fields, sometimes it clears most of the fields... I have really no idea of what I'm doing :o. |
So it happens for the examples as well? |
It does not fail because the examples are simple BUT I did have a lose of some information from local storage. Most of the time, each values from the local storage is removed expect access token and authenticatorFactory. Now, I understand why MY code fails. Because it relies on some information that are destroyed. In my initializer: Ember.SimpleAuth.Session.reopen({
user: function() {
var userId = this.get('owner_id');
if (Ember.isNone(userId)) {
return null;
}
return container.lookup('store:main').find('user', userId);
}.property('owner_id')
}); However, the "owner_id" property is always removed from local storage when I changed tab. So user returns null, and breaks the whole code. But as the "access_token" is still in the local storage, Ember-Simple-Auth assumes I'm authenticated, hence it tries to get the user, and fails. |
I'm trying using the Cookie store, and it seems to work properly. No data is getting removed from the cookies! So it seems the bug is clearly coming from LocalStorage. |
Thanks for the research - will look into it in the next days. |
Thanks a lot :) |
I'm not able to get cookie or localStorage to work. Refreshing the page always loses all data. |
Would need some more information. Are you using a custom authenticator? Did you upgrade to 0.1.2 and register the authenticator as shown in the README? |
Should be fixed in master - unfortunately that stuff is a win to debug... |
Thanks. I'm gonna try and let you know. |
Hi. It seems much more stable, however I still have values from the local storage that disappear for no reason. I've been unable to reproduce the case, it just happens from times to times, for no reason :/. |
Can you setup a jsbin maybe that shows a case where values are lost? |
Update: the problem I described above was my own fault. I had not implemented restore in my custom authenticator which extended Ember.SimpleAuth.Authenticators.Base ... the default behavior of this method is to reject the restore attempt. My bad! |
@marcoow I've update to Also this is how data looks like in localstorage. |
There's definitely sth. very wrong. Looks like the jQuery object gets stored or so. Can you share your code somewhere? |
I think the problem is probably the Also the else case here https://gist.github.com/seifsallam/5beac9912c54621ea37c#file-auth-coffee-L34 will log the user out as it resolves with the passed in credentials which will lead the session to replace all its properties with these credentials effectively deleting the access_token.. I think it would make more sense for you to extend the OAuth 2.0 authenticator and simple override Ember.SimpleAuth.Authenticators.OAuth2.reopen({
serverTokenEndpoint: '<your-endpoint>',
makeRequest: function(data) {
data.email = data. username;
return this._super(data);
}
}); |
@marcoow Thanks it worked. The else case is used by the signup and oauth. After the signup or oauth requests succeeds, they return the same data as the As for OAuth. I used it before, but i found a lot of stuff that i didn't need. |
@marcoow hello, I am having similar issue in a fork of ember-cli-simple-auth-token... I was just about to submit my PR when I discovered that opening a 2nd tab instantly boots me out of both tabs... where should I even start to look for what causes that? any suggestions on what it could be? https://github.com/erichonkanen/ember-cli-simple-auth-token thanks! |
@erichonkanen ember-cli-simple-auth-token isn't actually part of Ember Simple Auth but an extension library that's maintained separately here. The kind of problem you describe is usually caused by custom authenticators with a missing or wrong implementation of the |
Hi,
I have a strange behaviour, I'm not sure it comes from Ember-Simple-Auth though. If I open my website in one tab, and then open the same in another tab, most of the values from the local storage are gone excepting "access_token" and "authenticator", which in turn throws an exception.
Can you try if you can reproduce the error?
The text was updated successfully, but these errors were encountered: