Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Auth - with Email and Password - Check user already registered

I want to check when a user attempts to signup with createUserWithEmailAndPassword() in Firebase user Authentication method, this user is already registered with my app.

Registered Users

like image 832
Coolbub Avatar asked Oct 13 '16 05:10

Coolbub


People also ask

Which of the following Auth service is provided by Firebase to check if user's email and password are registered or not?

You can use Firebase Authentication to let your users authenticate with Firebase using their email addresses and passwords, and to manage your app's password-based accounts.

Can we see user password in Firebase?

If you are u storing the user and password in firebase authentication then no it is not possible to view the password written by the user. You can store the password in the database but if someone got access to your database they can know all the passwords of the users using your application.

How do I log into Firebase with my email and password?

If you haven't yet connected your app to your Firebase project, do so from the Firebase console. Enable Email/Password sign-in: In the Firebase console, open the Auth section. On the Sign in method tab, enable the Email/password sign-in method and click Save.


2 Answers

To detect whether a user with that email address already exists, you can detect when the call to createUserWithEmailAndPassword () fails with auth/email-already-in-use. I see that @Srinivasan just posted an answer for this.

Alternatively, you can detect that an email address is already used by calling fetchSignInMethodsForEmail(). The usual flow for this is that you first ask the user to enter their email address, then call fetchSignInMethodsForEmail, and then move them to a screen that either asks for the rest of their registration details (if they're new), or show them the provider(s) with which they're signed up already.

like image 198
Frank van Puffelen Avatar answered Sep 21 '22 11:09

Frank van Puffelen


When the user trying to create an user with same email address, the task response will be "Response: The email address is already in use by another account."

mFirebaseAuth.createUserWithEmailAndPassword(email,password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {                           
                        if(task.isSuccessful()){
                           //User registered successfully
                        }else{
                            Log.i("Response","Failed to create user:"+task.getException().getMessage());
                        }
                    }
                });

Firebase Auth SignIn MethodAdvanced Setting

like image 28
Srinivasan Avatar answered Sep 21 '22 11:09

Srinivasan