1

I am developing a Flutter App and want to use Firebase Auth for user login. My problem is that I want to first ask for the email, check that the format is valid, and then send the user to a LogIn screen or SignIn screen depending on whether the email already exists on Firebase.

I read this question where it says that the only solution is to perform a signIn with createUserWithEmailAndPassword() method and check the error message, a solution that in the long term is not very reliable.

As flutter is evolving very fast, do you guys know of a better solution to accomplish this?

Thanks in advance!

2 Answers2

0

I think you could also create a cloud function to make that check in the server, that would be an alternative method. The question stated a restriction about making the check within the app.

As regarding making the check using the error message, that was already fixed and now you can check it using the error code. (I updated my answer)

Feu
  • 5,372
  • 1
  • 31
  • 57
0

As you are signing up means mostly you will save user's data like profile name or something. While signing up new user save user's email into firestore if it's first time. Then from next time run a query whether email is present in firestore or not, which implies whether user is already authenticated or not (first time or already created account). If no document found with that corresponding email means user is new guy , you can sign in. If document found with corresponding email then login user instead of sign up.

Harsha pulikollu
  • 2,386
  • 15
  • 28