Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在注册码中添加一层密码检查码_Java_Android - Fatal编程技术网

Java 在注册码中添加一层密码检查码

Java 在注册码中添加一层密码检查码,java,android,Java,Android,我目前在Firebase上有一个项目,我正在尝试验证新用户的身份。代码如下 if (!TextUtils.isEmpty(email_registration) && (!TextUtils.isEmpty(password_registration))) { mAuth.createUserWithEmailAndPassword(email_registration, password_registration).addOnCompleteL

我目前在Firebase上有一个项目,我正在尝试验证新用户的身份。代码如下

if (!TextUtils.isEmpty(email_registration) && (!TextUtils.isEmpty(password_registration))) {

                mAuth.createUserWithEmailAndPassword(email_registration, password_registration).addOnCompleteListener(Register.this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {

                        if (!task.isSuccessful()) {
                            Toast.makeText(Register.this, "Failed to create account. Please check", Toast.LENGTH_LONG).show();
                        } else {
                            Toast.makeText(Register.this, "Account created", Toast.LENGTH_LONG).show();
                        }
                    }
                });
            }
如果(!TextUtils.isEmpty(电子邮件注册)和(!TextUtils.isEmpty(密码注册))){
mAuth.createUserWithEmailAndPassword(电子邮件注册,密码注册)。addOnCompleteListener(Register.this,new OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
如果(!task.issusccessful()){
Toast.makeText(Register.this,“未能创建帐户。请检查”,Toast.LENGTH_LONG.show();
}否则{
Toast.makeText(Register.this,“Account created”,Toast.LENGTH_LONG.show();
}
}
});
}
我想实现的是一个简单的密码检查级别,我提出的代码如下。新变量password_confirm是用户再次输入密码的第二个字段

if (!TextUtils.isEmpty(email_registration) && (!TextUtils.isEmpty(password_registration))) {

                if (TextUtils.equals(password_registration, password_confirm)) {
                    mAuth.createUserWithEmailAndPassword(email_registration, password_registration).addOnCompleteListener(Register.this, new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {

                            if (!task.isSuccessful()) {
                                Toast.makeText(Register.this, "Failed to create account. Please check", Toast.LENGTH_LONG).show();
                            } else {
                                Toast.makeText(Register.this, "Account created", Toast.LENGTH_LONG).show();
                            }
                        }
                    });
                }
            }
如果(!TextUtils.isEmpty(电子邮件注册)和(!TextUtils.isEmpty(密码注册))){
if(TextUtils.equals(密码注册、密码确认)){
mAuth.createUserWithEmailAndPassword(电子邮件注册,密码注册)。addOnCompleteListener(Register.this,new OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
如果(!task.issusccessful()){
Toast.makeText(Register.this,“未能创建帐户。请检查”,Toast.LENGTH_LONG.show();
}否则{
Toast.makeText(Register.this,“Account created”,Toast.LENGTH_LONG.show();
}
}
});
}
}
但是,我认为这个逻辑不起作用,因为当两个if语句都满足时,就没有理由不进行身份验证(即,最后的else语句没有用处)。我也无法想出任何方法来实现这一点,因为addOnCompleteListener和if-else语句必须存在


我来自Python的背景,我们可以只设置2个if语句,然后启用mAuth,并将其他情况设置为“禁用”mAuth。我不知所措,希望能在这里得到一些帮助。谢谢。

你说的“不工作”是什么意思?我也看不到这些
分支,否则你所指的那些分支可能是多余的。我可以想到注册失败的其他原因,比如现有的电子邮件地址、无效的电子邮件地址、太不安全的密码(我认为firebase有类似的东西)我是指结尾的else语句