[英]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.