Sign in with phone number without otp vérification (android+firebase)

Viewed 377

I sign up with email and phone number(+ otp vérification) and password . i link Multiple Auth like picture bellow .

enter image description here

I want to sign in with phone number or email (same edit text) and password without otp vérification

mLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            if( !validateEmail()|!validatePassword()){
                return;
            }
            mProgress.show();
            final String EmailOrPhone=mEmailOrPhone.getEditText().getText().toString();
            final String password=mPass.getEditText().getText().toString();
            
            //if sign in with email 
            if (EmailOrPhone.matches("[a-zA-Z0-9._-]+@[a-z]+\.+[a-z]+")){
                 
          mAuth.signInWithEmailAndPassword(email,password).addOnCompleteListener(ClientLoginAct.this, 
          new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (!task.isSuccessful()){
                        mProgress.dismiss();

                        Snackbar.make(v, "Email or Password incorrect", Snackbar.LENGTH_LONG).show();
                        //Toast.makeText(ClientLoginAct.this,"Email or Password incorrect ",Toast.LENGTH_SHORT).show();
                    }
                }
            });
            }

            //if sign in with phone 
            if(EmailOrPhone.matches("[0-9]")){


                 /////////////////  What I put here to sign in, I want to sign in with phone number and password without otp vérification ////////////
            }   
        }
    });
1 Answers

You can show on UI that you are signing in with phone and password but in backend:

  1. Search for the user who has the number registered with his account same as entered by the user.
  2. Get that user's email from (real-time database)
  3. Sign in with email and password. You will signIn with email and password here but user will understand that he has signed with phone and password.
Related