Different permissions Firebase Auth

非 Y 不嫁゛ 提交于 2019-12-11 04:18:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!