Fabiola Salomone
Fabiola Salomone

Reputation: 13

User registration fails with Firebase in Android

Can you help me understand why this class does not refrain the user? In practice, when I enter email, password, etc. then I click on registration gives me that the user has not been registered, how can I do?

    public void singUpUser(final String email , final String password, final String nickName, final String confermaPassword) {

        final ProgressDialog dialog = new ProgressDialog(mContext);
        dialog.setMessage("Stiamo registrando l'utente....");
        dialog.setCancelable(false);
        dialog.show();

        mAuth.signInWithEmailAndPassword(email,password)
                .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            // Sign in success, update UI with the signed-in user's information
                            Log.d(TAG, "crearUterWithEmail:Success");
                            dialog.dismiss();
                            Map<String,Object> creaUtente = new HashMap<>();
                            creaUtente.put("email", email);
                            creaUtente.put("password", password);
                            creaUtente.put("nickName", nickName);
                            creaUtente.put("confermaPassword", confermaPassword);
                            mDatabase.child("Utente").child(task.getResult().getUser().getUid()).updateChildren(creaUtente);

                            Intent intent = new Intent(mContext, activity_singIn.class);
                            mContext.startActivity(intent);
                        } else {
                            dialog.dismiss();
                            // If sign in fails, display a message to the user.
                            Log.w(TAG, "crearUterWithEmail:failure", task.getException());
                            Toast.makeText(mContext, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();

                        }
                    }
                });
    }
    }

Upvotes: 0

Views: 123

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 139039

When you're getting the following error:

There is no user record corresponding to this identifier. The user may have been deleted.

Most likely means that you're trying to use the credentials of a user that doesn't exist in Firebase authentication anymore. A possible reason would be, that you deleted it.

To solve this, you have to create the user again, using createUserWithEmailAndPassword() and right after that try to sign in using signInWithEmailAndPassword().

Upvotes: 1

Related Questions