1

I always use firebase to login authentication, but this time I've a problem. My new application works with two types of users, the admin and the normal users.

How can I distinguish these two types in firebase?

1 Answers1

0

You can use Firebase Database with an object combining Firebase UserId and Role

public class User {
    public String userId;
    public String role;

    public User(String userId, String role) {
        this.username = username;
        this.email = email;
    }
}

To write :

mDatabase = FirebaseDatabase.getInstance().getReference();
private void writeNewUser(String userId, String role) {
    User user = new User(name, role);

    mDatabase.child("users").child(userId).setValue(user);
}
Dany Pop
  • 3,590
  • 2
  • 21
  • 28