Execute different logins from the same smartphone

Is it possible to execute different logins from the same smartphone?

I did it all the time and i figured out that should not be done. That’s why i get strange data and behavior. Each time i install the app, a new local database is created (or OPENED if it already exists). So i think that if i login with a user, then i logout and i login again with a different user, i mess up the local database, and also the remote database due to the pull/push replication mechanism.

Is there a way to overcome this issue or i’m forced to login always with the same user using the same smartphone?

You can definitely log in with different users, but you’ll probably want to use a different local database for each user, otherwise you’ll be combining different users’ documents in the same database.

Our ToDoLite application handles multi-user logins. I believe it creates a local database whose name is based on the username the user logs in with.

1 Like

Oh, ok. Now i solved this problem (i think…).

Just two more things:

I’m using a basic authentication (username/password), so:

  1. what should happen if i try to login with the same user from two different devices?
  2. how can i register a new user from the app?
  1. Logging in as the same user on two devices is fine. Each device will get changes made by the other when it syncs. You will have to watch out for document conflicts, if both devices might modify the same documents, and merge them appropriately.
  2. Sync Gateway’s user registration API is available on the admin port only, for security reasons. If you want the app to register an account, you’ll need to implement an API on your own app-server for the mobile app to call, and then have the app server use the SG admin API to create the account.
1 Like