I want my users to sign in with multiple accounts (Not linking multiple providers)
like gmail, it allows you to use multiple signed in accounts at the same time you
I was thinking about this issue, reading through the documentation and found that you can re-authenticate a user by credential. So maybe you can do it this way:
when a new user wants to sign in you take his info as AuthCredential
object like this:
AuthCredential credential = EmailAuthProvider.getCredential("user@example.com", "password1234");
//there is also GoogleAuthProvider, FacebookAuthProvider...
then to actually signing him in you use signInWithCredential(AuthCredential)
:
FirebaseUser user = FirebaseAuth.getInstance().signInWithCredential(credential);
Now you need to save the credential
object and the user
object somewhere safe.
If you want to add new user you do the same and save the new objects.
After that whenever in your app you want to switch between the users you get that user's object and call reauthenticate(AuthCredential)
method:
myFirstUserObject.reauthenticate(myFirstUserCredential);
I didn't really test this, you think it could work? I don't know exactly how to save the objects and if there is a safe way to implement it without exposing each user's credential?