-3

I’m having a struggle with a web app. I have 2 different types of users. One user is an admin, and the other user is a customer of the admin. I want both users to authenticate differently. For example, I want the admin user to login with email and password to access their dashboard and see the orders from their customers. Meanwhile, I want the customers of the admin to login with their phone number to make orders. My main struggle is that I don’t see a way where I only have one table for users in the database because some login with their email and password and some login with their phone number. How do I implement this in one app? Do I need to create 2 different apps? Any advice is appreciated.

1
  • 1
    Login with phone number is very unusual. I wouldn’t want to give me phone number to random people. If these are customers, expect to lose customers. – gnasher729 May 4 at 5:33
1

The table setup in the database is no problem: either you have the "normalized" solution where one table maps user name to authentication method with a primary key of userid, then you have one table per method. Or you have the "denormalized" one where you just put all the data in one row in the user table.

Of more concern is "log in with phone number" - phone numbers aren't a secret!

Not the answer you're looking for? Browse other questions tagged or ask your own question.