0

I have user Types in my database.

Types - "A" - Admin "D" - Developer "P" - programmer "T" - tester

I want to add user when admin loggedin to my appplication. For that i use

mAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d("log_tag", "signIn:onComplete:" + task.isSuccessful());

                    if (task.isSuccessful()) {
                        onAuthSuccess(task.getResult().getUser());
                    } else {
                        progressDialog.dismiss();
                        Toast.makeText(CreateUserActivity.this, getResources().getString(R.string.sign_in_failed),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });


private void onAuthSuccess(FirebaseUser user) {
    // Write new user
    if (!selectedKey.equalsIgnoreCase(""))
        writeNewUser(user.getUid(), userFirstName.getText().toString().trim(), userLastName.getText().toString().trim(), empJoinDate.getText().toString().trim(), userDesignation.getText().toString().trim(), selectedKey, selecteduserRole);

}

private void writeNewUser(String uid, String userFirstNam, String userLastName, String userJoinDate, String userDesignation, String departmentKey, String selectedUserRole) {
    ModelUser user = new ModelUser(userFirstNam, userLastName, userJoinDate, userDesignation, departmentKey, selectedUserRole);
    mDatabase.child(CV.ROOT_USERS).child(uid).setValue(user);
    addUserToDepartment(mDatabase.child(CV.ROOT).child(CV.DEPARTMENTS).child(departmentKey), uid);
}

As per the document HERE, it clearly shows that user will also signin with our application. But i don't want to signin with newly created user.

I only want to sign up new user and add it to my firebase database. Can you please help me to avoid logged in with new user as i am already logged in with my admin account

Arpit Patel
  • 1,561
  • 13
  • 23
  • When you create a user, there is currently no way to prevent the user from being signed in. There are some creative workaround, such as the one described here: http://stackoverflow.com/questions/37517208/firebase-kicks-out-current-user – Frank van Puffelen Oct 25 '16 at 14:32
  • Thank you @FrankvanPuffelen for reply.. But i was wondering, Is that the good way to create multiple app configuration in one project in android. How can we manage 2 app references in one project with single google-services.json – Arpit Patel Oct 26 '16 at 04:32
  • One way i got from SO is http://stackoverflow.com/questions/37634767/how-to-connect-to-more-than-one-firebase-database-from-an-android-app But still i am not sure, what about my app data security... I have to manage the users in both application.. Some users from my default and and some is from secondary... – Arpit Patel Oct 26 '16 at 05:25
  • I have solved this with creating other application in same project... Thanks @FrankvanPuffelen for guiding me with this. – Arpit Patel Oct 27 '16 at 08:01

0 Answers0