Skip to content Skip to sidebar Skip to footer

How To Create Two User Groups In Firebase Web

I am developing a web app which uses Firebase Authentication and Real-time Database. The sign-in method is via Google and then if the user is new he/she will be ask if whether he/s

Solution 1:

[UPDATED]

You could try this the simple way:

  1. Create a JSON object to store the users information in a field depends on the usage:

    • a field isTeacher of type boolean (assume you won't add other user type) or
    • a field userType of object contain all the feature types (isTeacher: boolean, isStudent: boolean, isHeadmaster:boolean, etc.) or
    • a field of userType of type string
  2. Create a method or condition to check the field of the user document whether is true for a particular user type / compare string (depends which one you use) by using if or switch case

  3. Under each case / condition, show the elements of the web according to their privilege.

  4. After signed-in, before the page load, do the checking using the function created

Post a Comment for "How To Create Two User Groups In Firebase Web"