I am trying to make a Master User module, which user can delete other users. I read from other questions, that if you want to delete a user, You must logged in as that user. And then, I realize that you could sign in with credential information stored by firebase auth. (for references, I use google, facebook and email method).
I also store a User entity in my Firebase Database which correspond to Firebase Auth. Here is my User class :
public class User {
// variables.
private String appId;
private String email;
private String name;
private String description;
private String photoUrl;
private boolean isAdmin;
private boolean isSuspended;
private boolean isDeleted;
private AuthCredential credential;
// all those getters and setters go here.
}
Notice that I store a AuthCredential instance in my user, which I set for the first time when I sign up this user, ( or sign in with facebook and google). Whenever I sign up / sign in, I got this error:
java.lang.RuntimeException: java.lang.InstantiationException: can't instantiate class com.google.firebase.auth.AuthCredential
BUT, I check my firebase database, and the credential is inserted.
Firebase Auth using email and password.
Firebase Auth using google provider.
My question is, what is the right method to store my user credential in firebase database and recover it again? Also, I don't know if what I'm doing is right, but my point is, I want to delete another user from some admin user. To do that, in my master user module, I'm gonna store my admin user credential, then I sign in as the user who will be deleted, delete myself, and the re-sign in to admin user by using stored admin user credential. Is there any other way to achieve this?
Thank You for your help.
EDIT
I got error whenever I do this :
User curUser = dataSnapshot.getValue(User.class);
... which is fine before I add AuthCredential instance in my user class.