skip to Main Content

Situation: I am working on an e-commerce project where a user has the option to do shopping and/or can do business as well.

Feature: To do shopping or to do business user has to create an account and for this purpose, I am using Firebase authentication to store User Credentials like Username and Password.

Problem: User trying to create an account for shopping with username (ex: [email protected]), but If the same user wants to do business with the same account then the user is unable to create the business account with the same username.

Question: So is there any way to store the same username/email with a different uid in Firebase authentication?

if the answer is no!

What will be another optimal solution to this problem?

Note: I have enabled to create multiple accounts for each identity provider but the error still exists.

ERROR: The email address is already in use by another account.

2

Answers


  1. Rather than creating a separate UID for the same email, you should maintain a table / record / collection containing access level or type of user (e.g, isBusiness/isCustomer) for each user.

    Login or Signup to reply.
  2. So is there any way to store the same username/email with a different UID in Firebase Authentication?

    No, you cannot have two different users with the same email address

    I have enabled to create multiple accounts for each identity provider but errors still exist.

    If you enable that, it doesn’t mean that you’ll have different users, you’ll just link an auth provider credentials to an existing user account.

    What will be another optimal solution to this problem?

    The simplest solution I can think of would be to add in the authentication screen an option to select what the user wants to do shopping or business. According to the selection, you can redirect the user to a specific screen. Please note that it’s an "or" operation. You cannot do both at the same time.

    If you need to differentiate the type operation in the database, then then Firestore schema might look like this:

    db
    |
    --- shopping (collection)
    |    |
    |    --- //shopping documents
    |
    --- business (collection)
         |
         --- //business documents
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search