简体   繁体   English

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

[英]firebase authentication with email and username and password

I am wondering if there is the ability to sign in with email and user id + password , I have a project that I want user to add a unique number ( actually it is our work identify number provided by our company ) to be able to sign in to the program will stay private to company employment .我想知道是否有使用电子邮件和用户ID+密码登录的能力,我有一个项目,我希望用户添加一个唯一编号(实际上是我们公司提供的工作标识号)以便能够签名在计划中将留私人到公司工作。

I need the firebase authentication to refuse login even if email and password are correct but the user id is wrong.即使电子邮件和密码正确但用户 ID 错误,我也需要 Firebase 身份验证来拒绝登录。

You can use the database to check if the id is the same or not.您可以使用数据库来检查 id 是否相同。

You can create the following database:您可以创建以下数据库:

users
   userId
      userCompanyId : id
      email         : email@gmail.com

So you can first authenticate the user based on his email and password and then, check if the id or unique number entered by the user is the same as the one in the database:因此,您可以首先根据用户的电子邮件和密码对用户进行身份验证,然后检查用户输入的 id 或唯一编号是否与数据库中的相同:

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

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

相关问题 没有用户名和密码的Firebase身份验证 - Firebase Authentication without Username and Password 如何在firebase上添加用户名,email和密码 - How to add username , email and password on firebase 如何将 Firebase 电话身份验证与电子邮件/密码身份验证联系起来? - How Can I Link Firebase Phone Authentication with Email/Password Authentication? 使用 Android 进行 Firebase 电子邮件和密码身份验证 - 用户注册 - Firebase Email and Password Authentication with android - User sign up Firebase 身份验证与 email 和密码额外字段重复 - Android - ZD52387880E15EA22817A723 - Firebase authentication with email and password extra fields duplicating - Android - Java Android Studio 的 Firebase 工具中缺少 Email 和密码验证 - Missing Email and Password Authentication in Android Studio's Firebase tool Firebase无法接收电子邮件/密码身份验证 - Firebase doesn't pick up email/password authentication 没有用户名/密码的自定义身份验证 - Custom Authentication without username/password 用户名和密码未在Spring中使用身份验证进行映射 - Username and Password not mapping with Authentication in Spring GlassFish身份验证的基本用户名和密码 - GlassFish authentication basic username and PASSWORD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM