0

No error message but it will kick off the current logged in user and make the newly created user the current logged in user for example If A creates new user B then B becomes current logged in user.

if (password.equals(confirmpassword)){
    firebaseAuth.createUserWithEmailAndPassword(email, password)
           .addOnCompleteListener(AddUserActivity.this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    progressbar.setVisibility(View.GONE);
                    if (task.isSuccessful()) {
                        user userinfo = new user(
                                firstname,
                                lastname,
                                email,
                                type,
                                adminkey
                        );
                        FirebaseDatabase.getInstance().getReference("AdminUsers")
                                .child(Objects.requireNonNull(FirebaseAuth.getInstance().getUid()))
                                .setValue(userinfo)
                                .addOnCompleteListener(new OnCompleteListener<Void>() {
                                    @Override
                                    public void onComplete(@NonNull Task<Void> task) {
                                        if (task.isSuccessful()) {
                                            Toast.makeText(AddUserActivity.this, "Email sent", Toast.LENGTH_SHORT).show();
                                        }

                                        Toast.makeText(AddUserActivity.this, "Registration completed", Toast.LENGTH_SHORT).show();
                                    }
                                });

                    } else {

                        Toast.makeText(AddUserActivity.this, "User already exist", Toast.LENGTH_SHORT).show();
                    }
         // ...
        }
    });
Constantin Beer
  • 5,447
  • 6
  • 25
  • 43
  • Can you explain in broad what you want to do ? Your information is not clear. – Ashish Aug 21 '19 at 07:52
  • I have a button inside User A(admin) called as Create User with the same sign up method I am creating and submitting the information. But once I create that new user let's say B then automatically user B becomes the current logged in user i.e A's auth becomes B's auth. But I just want to create the firebase new user. And want the current user A still logged in inside the app. – AJINKYA DHAS Aug 21 '19 at 08:40
  • If you dig little bit you can find [answer](https://stackoverflow.com/a/42040166/10182897). Your question is similar to that question and it can be marked as duplicate. – Ashish Aug 21 '19 at 08:53

0 Answers0