i want to check if user exist in firebase auth before register using email and password in addition to name, phoneNumber. So for example on sign up button i want to check if email is used by another user then if yes throw an error, if not it will take him to phone verification screen that will verify his phone number then if it is verified, user data will be store in firestore (email, uid, phoneNumber) with an account for the user. If not nothing will happin.
edit
i tried use sign in method to check the result but if the user put same email and same password, the user stream noticied a new user and i dont want that. i just want to check if he is exist before registering
for example:
this is my method for register
Future registerWithEmailAndPassword(String email, String password, String userName, String phoneNb, String gender) async {
try {
UserCredential result = await _auth.createUserWithEmailAndPassword(email: email, password: password);
User user = result.user;
await DatabaseService(uid: user.uid).updateUserData(userName,phoneNb,email, gender);
return _userFromFirebaseUser(user);
} on FirebaseAuthException catch (err) {
return err.code.toString();
}catch(err){
return "err is " + err.toString();
}
}
so i do this ==>
dynamic result = await _auth.registerWithEmailAndPassword(email, password, fname + ' ' + lname, phoneNumber, gender);
if(result== "instance of 'Servinera User'"){
//navigate to sms verification screen
}
else{
print("email already in use");}
firebase will create the account and input the data before sms verification :/ and i don't want that if phone not verified. or u suggest me that its okay??
help solving my problem What do u suggest me?