不同权限的Firebase身份验证 [英] Different permissions Firebase Auth
本文介绍了不同权限的Firebase身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我总是使用firebase登录身份验证,但是这次我遇到了问题. 我的新应用程序适用于两种类型的用户,即admin和普通用户.
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.
如何在Firebase中区分这两种类型?
How can I distinguish these two types in firebase?
推荐答案
您可以将Firebase数据库与结合了Firebase UserId和Role的对象一起使用
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;
}
}
要写:
mDatabase = FirebaseDatabase.getInstance().getReference();
private void writeNewUser(String userId, String role) {
User user = new User(name, role);
mDatabase.child("users").child(userId).setValue(user);
}
这篇关于不同权限的Firebase身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文