0

My app provides two types of users. I need to divide FirebaseAuth thus one user cannot access to the user group of the other and vice versa. I can't find a valid solution to do that. Any suggestions?

at the moment to create User in FirebaseAuth i use this method:

RaisedButton(
        elevation: 10,
        onPressed: rememberMe ? () async {
          try {
            final newUser =
            await _auth.createUserWithEmailAndPassword(
                email: InUser.email, password: password);

but I can't understand how to split the groups.

1 Answers1

1

There is no such concept directly implemented in Firebase Auth as far I know, but you have essentially 2 options:

  • as a custom claim in the Firebase Authentication token for that user

  • in the database using a User collection with documents associated with your users.

You should be setting the role from within a trusted environment (i.e. Cloud Functions or even manually) as otherwise anyone can change their own role if you do not secure your documents by access rules.

Once set in either of these locations, you can access the role information in your client-side code.

you may want to have a look at: https://www.youtube.com/watch?v=oFlHzF5U-HA

Julian2611
  • 422
  • 3
  • 11