Reputation: 133
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 .
I need the firebase authentication to refuse login even if email and password are correct but the user id is wrong.
Upvotes: 0
Views: 276
Reputation: 80914
You can use the database to check if the id is the same or not.
You can create the following database:
users
userId
userCompanyId : id
email : [email protected]
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:
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());
}
}
});
Upvotes: 1