1
votes

i have created a flutter app in which phone authentication is used for sign In process. User enters phone number then it is redirected to otp page n after verification user gets logged in.

So i want to check whether the user is an old or new user. When user enters the phone number then it must check whether the user exist in the Firebase Authentication, if yes redirect to otp screen or if not then it must show snackbar that user does not exist and redirect to sign up page.

So how should i search for the phone number in firebase authentication page in flutter?

3

3 Answers

1
votes

Such functionality only exists in the Firebase Admin SDKs, which are designed to run in a trusted environment (such as your development machine, a server that you control, or Cloud Functions). For example, here is the relevant call for Node.js: getUserByPhoneNumber.

If you want to use such functionality from the client-side, you will either have to wrap the Admin SDK call in an custom API that you build yourself, or you can do what biruk suggested and track the list of registered phone numbers in another data store, such as one of the databases that Firebase also offers.

1
votes

there is no way to check that you have to register the phone number in the database and check whether that phone number exists from that database.

1
votes

Currently there is no function to do that. What you can to is track the list of registered phone numbers inside Firestore database , and upon Sign-in check if the phone number exists in the db.Then you can authenticate that phone number using this guide .