ember-simple-auth: Refresh page causes logout
I use my custom authenticator whch is the same as device authenticator almost. When I refresh the page, local storage cleared and user logged out.
Ember version : 2.5.1
Ember Simple Auth version : 1.1.0
Why? Thanks in advance
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 50 (29 by maintainers)
Commits related to this issue
- Fix issue where store is emptied on page refresh Related #990 #1090. Early in the initialization of this object, `setUnknownProperty` gets called with `__OWNER__` and `__NAME_KEY__` (system proper... — committed to jamiechong/ember-simple-auth by jamiechong 7 years ago
- Fix issue where store is emptied on page refresh (#1267) * Fix issue where store is emptied on page refresh Related #990 #1090. Early in the initialization of this object, `setUnknownProperty` ... — committed to mainmatter/ember-simple-auth by jamiechong 7 years ago
You can store custom session data by setting it on the session:
That is how it currently works but also the reason for the problems I mentioned above - basically all data that is written to the session is automatically persisted to the store which leads to a lot of hacky and complex code. This needs to be refactored into a cleaner solution but as that’s a larger effort nobody has yet found the time to do it.
Ok so we have just hit this issue and I have tracked down the problem, our code was actually throwing an Exception in our authenticator’s
restoremethod (details of which are not too important)The problem is that the error is being swallowed and not ever output to the user. The problem is that if there is an error thrown at this point https://github.com/simplabs/ember-simple-auth/blob/master/addon/internal-session.js#L67 it will not be caught by this error handler: https://github.com/simplabs/ember-simple-auth/blob/master/addon/internal-session.js#L85 , instead that error handler will only catch issues with the
this._callStoreAsync('restore')call on this line https://github.com/simplabs/ember-simple-auth/blob/master/addon/internal-session.js#L62If the error handler is valid for cases of exceptions thrown in the user provided restore method then I would recommend changing the
internal-sessionrestoremethod to look more like this:The difference is that this will now catch all issues with user provided restore methods