0

My problem is that i want to create new user with method firebaseAuth.createUserWithEmailAndPassword(user.getEmail(), password), but after the creation of the new user i don't want to sign in automatically in the new user and just stay in current user. What am I supposed t do to stay in the same user account?

My code is like this:

public void addUser(User user, String password){

    firebaseAuth.createUserWithEmailAndPassword(user.getEmail(), password)
            .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {

                    if (task.isSuccessful()){

                        String userID = task.getResult().getUser().getUid();
                        FirebaseDatabase .getInstance().getReference(USERS_NODE)
                                .child(userID)
                                .setValue(user);

                    }
                }
            });
}
Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
  • Firebase Authentication automatically signs the users in by design, and there's no way to prevent it from doing so. While there is a workaround, I recommend reading the full answers in the link(s) as there are better ways to implement administrative functionality like this. – Frank van Puffelen Mar 13 '22 at 14:41

0 Answers0