When loading state on app init I get data from different app #153

Closed
opened 2016-08-16 08:23:20 +00:00 by EmilScherdin · 4 comments
EmilScherdin commented 2016-08-16 08:23:20 +00:00 (Migrated from github.com)

I'm building two apps and I'm using your package in both of them.

I have noticed that if I have the same save-key in both of the apps you will get the first apps data in the second app. So you load wrong data in the app. It should not be possible to load in data from another app to you app or am I missing something?

I'm building two apps and I'm using your package in both of them. I have noticed that if I have the same save-key in both of the apps you will get the first apps data in the second app. So you load wrong data in the app. It should not be possible to load in data from another app to you app or am I missing something?
michaelcontento commented 2016-08-16 11:08:32 +00:00 (Migrated from github.com)

Hi,

this completely depends on the redux-storage-engine you use!

For all engines I've created (for example redux-storage-engine-localstorage) your observation is indeed true.

In the case of redux-storage-engine-localstorage the scoping is only based on the browsers behaviour of localStorage.getItem and localStorage.setItem. So if you host both redux apps under the same domain the keyspace is shared.

With redux-storage-engine-reactnativeasyncstorage the scoping should be based on the appId (I haven't doubled checked this).

So from redux-storage point of view this detail is 100% in the hand of the engine. And for all my engines this behaviour is "by design". 😄

Is there anything wrong with this? Is there a special case why you host two different apps under the same domain? Is there anything that forces you to use a single save-key for multiple apps?

Hi, this completely depends on the [redux-storage-engine](https://www.npmjs.com/browse/keyword/redux-storage-engine) you use! For all engines I've created (for example [redux-storage-engine-localstorage](https://github.com/michaelcontento/redux-storage-engine-localstorage)) your observation is indeed true. In the case of [redux-storage-engine-localstorage](https://github.com/michaelcontento/redux-storage-engine-localstorage) the scoping is only based on the browsers behaviour of `localStorage.getItem` and `localStorage.setItem`. So if you host both redux apps under the same domain the keyspace is shared. With [redux-storage-engine-reactnativeasyncstorage](https://github.com/michaelcontento/redux-storage-engine-reactnativeasyncstorage) the scoping should be based on the appId (I haven't doubled checked this). So from `redux-storage` point of view this detail is 100% in the hand of the engine. And for all my engines this behaviour is "by design". 😄 Is there anything wrong with this? Is there a special case why you host two different apps under the same domain? Is there anything that forces you to use a single save-key for multiple apps?
EmilScherdin commented 2016-08-16 11:33:14 +00:00 (Migrated from github.com)

Hmm, okey.

I use the redux-storage-engine-reactnativeasyncstorage. And it's no actual problem for me using two different save-keys. This is what I'm doing now. 😄

But it feels wrong that i could get access to the first apps data from the second app. If that would happen with other apps on the users phone it's pretty bad.

If redux-storage-engine-reactnativeasyncstorage scopes on appId, this should not be able to happen?

Hmm, okey. I use the redux-storage-engine-reactnativeasyncstorage. And it's no actual problem for me using two different save-keys. This is what I'm doing now. 😄 But it feels wrong that i could get access to the first apps data from the second app. If that would happen with other apps on the users phone it's pretty bad. If redux-storage-engine-reactnativeasyncstorage scopes on appId, this should not be able to happen?
michaelcontento commented 2016-08-16 12:06:24 +00:00 (Migrated from github.com)

Hm .. redux-storage-engine-reactnativeasyncstorage is simply based on AsyncStorage.getItem and AsyncStorage.setItem (as you can see here). I haven't double checked this but I would assume that react-native keeps the AsyncStorage seperated by app.

If there is something wrong and/or buggy, please report this issue to the react-native team!

Hm .. `redux-storage-engine-reactnativeasyncstorage` is simply based on `AsyncStorage.getItem` and `AsyncStorage.setItem` (as you can [see here](https://github.com/michaelcontento/redux-storage-engine-reactnativeasyncstorage/blob/master/src/index.js#L5)). I haven't double checked this but I would assume that react-native keeps the `AsyncStorage` seperated by app. If there is something wrong and/or buggy, please report this issue to the react-native team!
EmilScherdin commented 2016-08-16 12:14:23 +00:00 (Migrated from github.com)

Okey, will dig a bit deeper in to it. Thanks for the quick replies! 👍 🎉

Okey, will dig a bit deeper in to it. Thanks for the quick replies! 👍 🎉
This discussion has been locked. Commenting is limited to contributors.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MichaelContento/redux-storage#153
No description provided.