问题
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:
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);
}
来源:https://stackoverflow.com/questions/44595878/different-permissions-firebase-auth