繁体   English   中英

用户注册失败,Android 中的 Firebase

[英]User registration fails with Firebase in Android

你能帮我理解为什么这个 class 不克制用户吗? 在实践中,当我输入email、密码等然后我点击注册给我说用户还没有注册,我该怎么办?

    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();

                        }
                    }
                });
    }
    }

当您收到以下错误时:

没有与此标识符对应的用户记录。 该用户可能已被删除。

很可能意味着您正在尝试使用 Firebase 身份验证中不存在的用户凭据。 一个可能的原因是,您删除了它。

要解决此问题,您必须使用createUserWithEmailAndPassword()再次创建用户,然后尝试使用signInWithEmailAndPassword()登录。

埃科拉:

 public void singInUser(String email, String password) { ProgressDialog dialog = new ProgressDialog(mContext); dialog.setMessage("Accesso...."); 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, "signInWithEmailAndPassword:Esiste"); dialog.dismiss(); Intent intent = new Intent(mContext, activity_Home.class); mContext.startActivity(intent); } else { dialog.dismiss(); // If sign in fails, display a message to the user. Log.w(TAG, "signInWithEmailAndPassword:failure", task.getException()); Toast.makeText(mContext, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM