0

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

Mahi Tej Gvp
  • 984
  • 1
  • 14
  • 34

1 Answers1

1

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.

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.

Nick Zisis
  • 288
  • 2
  • 12
  • hey Nick . I have separated the users in different database structures but how do i get to know wether a paticular user is a teacher or not without accesing the Database only through Firebase user – Mahi Tej Gvp Sep 18 '17 at 09:36
  • You can accomplish that with 2 ways. 1) You can create a different UI for teacher and student login screen and create 2 different methods corresponding to the selected UI. Or after a user sign up for the first time in the app you can indicate if it is a teacher or student and save a boolean value in SharedPreferences and also his email for the next sign in. But I will go with the first solution which is more clean in the logic and easier to implement it. – Nick Zisis Sep 18 '17 at 10:14
  • If you found my answer correct and helped you, can you mark the answer as the accepted one and vote up. Thanks in advance. – Nick Zisis Sep 19 '17 at 13:30
  • Not quite nick i am looking a different way – Mahi Tej Gvp Sep 19 '17 at 13:51