I am trying to figure out how to address the issue of what to do when the email already exists in certain situations. I am currently using firebase, but I believe it would be the same problem no matter what software you use. Is there a standard way to do this?
Example:
- Login with Email / Register
- if "email" exists then error( EMAIL_EXISTS )
- else create account & login
user must verify email
EMAIL_EXISTS = "Please login with your <%provider%> account, your email already exists"
- Login with Provider (google, fb, twitter, etc) / Register
- If "email" exists then add provider to account providers
- else create account (possibly ask for new password) & login
- Login with Email
- Click Connections / Providers
- Add Google / Facebook / Twitter etc to account
Is there a standard way to do this? I feel like I am missing some steps. I keep seeing many apps that do not address the issue and you must have a different account for each provider which is different than your email account. Obviously a good programmer thinks about these things.
How should I go about this?
The first 4 steps are pretty much how you should implement it with Firebase Authentication if you have the One account per email address setting enabled (which it is by default) in your Firebase Authentication console.
But if you want this flow in your app, I highly recommend checking if there is a FirebaseUI library with Auth for your platform. It exists for iOS, Android, and Web, and implements many common auth flows in a consistent way.