Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.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/1/firebase/6.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 使用电子邮件、用户名和密码进行firebase身份验证_Java_Firebase_Firebase Authentication - Fatal编程技术网

Java 使用电子邮件、用户名和密码进行firebase身份验证

Java 使用电子邮件、用户名和密码进行firebase身份验证,java,firebase,firebase-authentication,Java,Firebase,Firebase Authentication,我想知道是否有能力登录与电子邮件和用户id+密码,我有一个项目,我希望用户添加一个唯一的号码实际上这是我们的工作识别号码提供了我们的公司能够登录到该计划将保持私人公司就业 我需要firebase身份验证来拒绝登录,即使电子邮件和密码正确,但用户id错误。您可以使用数据库检查id是否相同 您可以创建以下数据库: users userId userCompanyId : id email : email@gmail.com mAuth.createUs

我想知道是否有能力登录与电子邮件和用户id+密码,我有一个项目,我希望用户添加一个唯一的号码实际上这是我们的工作识别号码提供了我们的公司能够登录到该计划将保持私人公司就业


我需要firebase身份验证来拒绝登录,即使电子邮件和密码正确,但用户id错误。

您可以使用数据库检查id是否相同

您可以创建以下数据库:

users
   userId
      userCompanyId : id
      email         : email@gmail.com
mAuth.createUserWithEmailAndPassword(email, password)
        .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()) {
                      // retrieve Id from database and check if it is the same
                } else {
                    //sign in failed
                    Log.w(TAG, "createUserWithEmail:failure", task.getException());
                }
            }
        });
因此,您可以首先根据用户的电子邮件和密码对其进行身份验证,然后检查用户输入的id或唯一编号是否与数据库中的相同:

users
   userId
      userCompanyId : id
      email         : email@gmail.com
mAuth.createUserWithEmailAndPassword(email, password)
        .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()) {
                      // retrieve Id from database and check if it is the same
                } else {
                    //sign in failed
                    Log.w(TAG, "createUserWithEmail:failure", task.getException());
                }
            }
        });

这确实是普遍的做法。您甚至可以考虑为此实现自定义提供程序,尽管您必须自己存储更多的信息,因为管理员SDK无法在该实例中验证您的凭据。请您帮助我登录活动,以便能够为我检查一下。我在帖子中添加了我的登录和注册活动,敬请。请检查我的代码,并告诉我在数据库中创建ID的创建顺序应该放在哪里,以及在登录时将代码放在哪里。请在问题中添加您的代码,而不是在我的回答中添加您的代码