Reputation: 107
I am using firebase Email/password authentication for both signup and sign in. However during the Sign up process I would like to get the user UID and use that to create a new database in firebase with other user information like Name and phonenumber. I know its easier to get the UID with a login process, however is there a way to do this with signup, assuming sign up has been successful. I am using android studio.
Upvotes: 2
Views: 5228
Reputation: 38319
You can get the user information from the task returned by the completion listener:
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
if (task.isSuccessful()) {
FirebaseUser user = task.getResult().getUser();
Log.d(TAG, "onComplete: uid=" + user.getUid());
}
}
});
Upvotes: 4