IndexedDb per multiple users

百般思念 提交于 2019-12-24 02:43:15

问题


I have a question about IndexedDb best practices, how to manage different users' data.

Scenario: I have a mysql database containing system data. When user login to the system, I synchronize his data from mysql into IndexedDb and then web application uses data stored directly in indexeddb. When user login next time to the system, full synchronization is not needed because his data is already stored locally.

Problem is when user logs out, and then on the same computer another user login into the system, because IndexedDb contains data for previous user.

Is there any best practice for managing such scenario? Because for now I see 2 options:

  1. On the logout and login action always clear indexeddb data. Disadvantage is that in that case every time user login to the system I need to perform full synchronization.
  2. Get rid of IndexedDb, because it shouldn't be used for that scenario and get data directly from mysql.
  3. ?? <- Please maybe you have an idea how to avoid full synchronization every time user login, and keep another users data safe from reading.

Thanks,


回答1:


The practice I employed was not to store multiple accounts on the same machine. That is a security risk that could allow someone to view the data from accounts that they don't have permission to. Instead, when I detect that a user signs out and then a different user signs back in, I delete the currently cached data before saving the data from the new user. If a person signs out and the same user signs back in, I never delete their data. It only gets deleted when users change.



来源:https://stackoverflow.com/questions/27067267/indexeddb-per-multiple-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!