0

I'm using Custom Tokens (createCustomToken() and signInWithCustomToken()) for user authentication which accepts a userID and email, and an intermediate step verifies the email by sending a one time password.

It was all great until I just ran into an issue which is a major roadblock:

{
  code: 'auth/email-already-exists',
  message: 'The email address is already in use by another account.'
}

Quite a few users share the same email address because there are main accounts (parent) and sub-accounts (children) so although the user ID is different but the email is same.

I really hope there's a way to enable users with the same email addresses?

eozzy
  • 66,048
  • 104
  • 272
  • 428

1 Answers1

0

There is no way in Firebase to allow multiple accounts with a single email address within a single provider. After all, how would you distinguish between these multiple accounts when the user tries to sign in.

A common workaround for the scenario you describe is to add a descriptor to the email address for the person, like mainaddress+tommy@domain.com vs mainaddress+pam@domain.com. Firebase will consider these separate email addresses, while the email provider will deliver them to the same mainaddress@domain.com mailbox.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I did think about that workaround but unfortunately not all email providers support aliasing. :( I have just manually created the users with an email userID@mydomain.com and it seems to work because the email I actually use to send OTP is the one from the Firestore based on the userID provided. – eozzy Sep 04 '22 at 15:47