如何在firebaseAuth中区分不同级别的用户 [英] How do i differentiate between different level of users in firebaseAuth
问题描述
我有两种不同类型的用户教师和学生.我使用带有电子邮件和密码的Firebase身份验证来对它们进行身份验证并将其存储在Firebase实时数据库中.我的问题是,有没有一种方法可以创建自定义accesor方法,例如getCurrentUser().getEmail,getDisplayname等.我需要针对当前用户类型的不同用户类型(教师/学生)显示不同的用户界面
I have two different types of users Teachers and Students . I use Firebase Auth with Email and password to Authenticate them and store them in the Firebase Real time database . My question is is there a way to create custom accesor methods such as getCurrentUser().getEmail, getDisplayname etc . I need to display different UI for different user type (Teacher/Student) from the current user-type
推荐答案
您有两种类型的用户.因此,首先,您只能为两个用户创建一个Firebase结构,只需添加一个布尔变量TEACHER即可指示用户是老师还是学生.
You got 2 type of users. So first of all, you can make only one firebase structure for both user and just add a boolean variable TEACHER that indicates if a user is a teacher or a student.
但是我通常要做的是将用户分成两个不同的firebase结构,这意味着您应该创建一个firebase路径teacher/user_id和另一个student/user_id,这将使您可以灵活地检索数据并在不同的UI中显示数据
But what I usually do is to seperate the users in two different firebase structures meaning that you should create a firebase path teacher/user_id and an another student/user_id which will give you flexibility with retreiving data and display the data in different UI.
这篇关于如何在firebaseAuth中区分不同级别的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!