mercredi 30 septembre 2020

How to handle multi-users in sqflite Flutter

I build an application using Flutter and implemented my DB with sqflite,
I'm using Firebase only as my authentication (login screen).

The problem occur in the next scenario:

Lets say a User open the application for the first time and preform the registration after that he goes and login into the application. now the DB is created and the user add some items ,after adding those item the user logout and preform registration with different email then goes and login. and get access to the previous User that added the items before.

Possible solutions to implement:

  1. Delete DB when user logout (not really recommended)
  2. Using the Firebase auth token meaning saving the token or the email in each item that saves and extract data that only use the same token or email.
  3. Use firebase DB and let him handle the mess. (wanted to avoid this to prevent chargers)

If you have any ideas how to handle multi users in sqflite will be glad to see some code example. as mentioned my DB is working and the application working my problem is implementing multi users approach.

Aucun commentaire:

Enregistrer un commentaire