Log in through either email or phone

Database & APIs

Couldn't find any questions like this. In my app I want to give users the ability to log-in through either phone/password or email/password. What is the best way to do that? I'm using firebase for authentication and database/storage.

What have you tried so far?

From my understanding, one way I thought of to do this was as follows:

  1. Have two fields on login page, phone/email and password

  2. In actions, check if the first field matches either a phone mask or email mask

  3. Go through the entire firebase, to find that email/phone and then check if the password fits. I have no idea how access rules would work then, as I have an unathenticated user check for both email/phone and password. I also feel there are other problems with this that I'm not seeing.

I'm worried this is too complicated and might be slow if there's a lot of users in the database. Would it be easier with some other authentication service? Has anyone else done this? And how do I register a user?

Did you check FlutterFlow's Documentation for this topic?
Yes
1
5 replies