Email and password in the Android Studio app not registered in Firebase

Asked

Viewed 66 times

0

No type of error appears when I click to register the button, I have put all types of password sizes and even put my own valid email only that does not register in firebase authentication.

private void Cadastrar() {

    nome = (EditText) findViewById(R.id.edit_cadastro_nome);
    email = (EditText) findViewById(R.id.edit_cadastro_email);
    senha = (EditText) findViewById(R.id.edit_cadastro_senha);
    botaoCadastar = (Button) findViewById(R.id.bt_cadastrar);

    botaoCadastar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            usuario = new Usuario();
            usuario.setNome(nome.getText().toString());
            usuario.setEmail(email.getText().toString());
            usuario.setSenha(senha.getText().toString());
            cadastarUsuario();
        }
    });
}

private void cadastarUsuario(){

    autenticacao = ConfiguracaoFireBase.getFirebaseAutenticacao();
    autenticacao.createUserWithEmailAndPassword(
            usuario.getEmail(),
            usuario.getSenha()
    ).addOnCompleteListener(CadastroUsuarioActivity.this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if(task.isSuccessful()){
                Toast.makeText(CadastroUsuarioActivity.this,"Sucesso ao cadastrar", Toast.LENGTH_LONG).show();
                Log.i(usuario.getEmail(), "Erro");
            }else{
                Toast.makeText(CadastroUsuarioActivity.this,"Erro ao cadastrar", Toast.LENGTH_LONG).show();
            }

        }
    });
}

FIREBASE CONFIGURATION

public final class ConfiguracaoFireBase {

    private static DatabaseReference referenciaFirebase;
    private static FirebaseAuth autenticacao;

    public static DatabaseReference getFirebase() {

        if (referenciaFirebase == null) {
            referenciaFirebase = FirebaseDatabase.getInstance().getReference();
        }

        return referenciaFirebase;
    }

    public static FirebaseAuth getFirebaseAutenticacao(){

        if(autenticacao == null){
            autenticacao = FirebaseAuth.getInstance();
        }
        return autenticacao;
    }
}
  • What’s in this class ConfiguracaoFireBase? Where and how you define the variable usuario?

  • is where I connect with firebase

2 answers

1

I don’t see any problem with the code.

Maybe what’s missing is enabling the email/password authentication option in Firebase.

inserir a descrição da imagem aqui

1

Maybe your firebase rule file is restricting insertion.

Take a look at this link and see if it helps you.

  • my rules are correct

Browser other questions tagged

You are not signed in. Login or sign up in order to post.