Reputation: 75
I'm using Firebase for authentication and Cloud Firestore as a Database in my app. To link a user to their data a created a Users collection and each document name is a UserId that I get from Firebase Auth. My problem is if a user creates an account using email and password but then signs in using the same email but with Google Authentication instead, the Google Auth overwrites the Email and Password Authentication and the UserId changes.
Upvotes: 0
Views: 874
Reputation: 40582
It does not overwrite the email/password account. Indeed both will still exist if you check the user list in the console.
What happens here is that logging in with a different provider generates a separate set of credentials. So a new User ID is created. They are different credentials and only the warm body sitting at the keyboard knows if they happen to be owned by the same fleshbag of DNA and water.
Note that you can link accounts together. So if you want to treat providers who share an email address as the same user, you can check the email accounts and ask the user to link them by signing into each account during a single session.
Upvotes: 3