--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/76d32dad-6cd0-449c-854b-c161ab4718ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
First of all, you should create the users keyed by the user id, rather than random document ids. That will help later when you're trying to write security rules and read user accounts.There are two ways to handle the memberships. If the relationship is always 1:1 and that will never change, you could just namespace each group and move users between the groups. So a structure like follows:
/teams/$team/users/$user/teams/$team/widgets/$widgetAnd then you'd simply write security rules to restrict access at the $team level based on whether exists(/databases/$(database)/teams/$(team)/users/$(request.auth.uid));But the more common structure here is probably to do a bit of duplication, as this is a bit more flexible and allows many-to-many relationships:/users/$user/teams (an array of team ids)/teams/$team/members (an array of user ids)And now your teams path is secured with something like request.auth.uid in get(/databases/$(database)/teams/$(team)/members).data;And if you have a user id, you can reverse look up access in the same way: $(teamId) in get(/databases/$(database)/users/$(request.auth.uid)/teams).data;
I hope that helps!
☼, Kato
On Fri, Apr 12, 2019 at 1:21 PM herantd <hera...@gmail.com> wrote:
--Hi,I am currently working on an PWA that will serve as a company portal. The idea is that the user who is employed by company (A) will be part of a team, let's say team: "red". The user who logs in will only have access to the people who are on the same team as this user. For example, company (A) will consist of several teams, and the portal will consist of several companies.I wonder what is the best way to structure the database so that at a later time if the administrator wants to move a user over to another team then it is as easy as just a keystroke.I have created a database that starts with "users", then contains a list of documents that act as a user ID. Inside the collection, it says which company the user belongs to and which team and the ID are equal to the user's login (Authentication) id. I am quite new with databases and firebase, so it would have been nice to know what is the best way to construct such a system.
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/76d32dad-6cd0-449c-854b-c161ab4718ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/04d19a6f-2123-4830-b46e-0080e37db61a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
First of all, you should create the users keyed by the user id, rather than random document ids. That will help later when you're trying to write security rules and read user accounts.There are two ways to handle the memberships. If the relationship is always 1:1 and that will never change, you could just namespace each group and move users between the groups. So a structure like follows:
/teams/$team/users/$user/teams/$team/widgets/$widgetAnd then you'd simply write security rules to restrict access at the $team level based on whether exists(/databases/$(database)/teams/$(team)/users/$(request.auth.uid));But the more common structure here is probably to do a bit of duplication, as this is a bit more flexible and allows many-to-many relationships:/users/$user/teams (an array of team ids)/teams/$team/members (an array of user ids)And now your teams path is secured with something like request.auth.uid in get(/databases/$(database)/teams/$(team)/members).data;And if you have a user id, you can reverse look up access in the same way: $(teamId) in get(/databases/$(database)/users/$(request.auth.uid)/teams).data;
I hope that helps!
☼, Kato
On Fri, Apr 12, 2019 at 1:21 PM herantd <hera...@gmail.com> wrote:
--Hi,I am currently working on an PWA that will serve as a company portal. The idea is that the user who is employed by company (A) will be part of a team, let's say team: "red". The user who logs in will only have access to the people who are on the same team as this user. For example, company (A) will consist of several teams, and the portal will consist of several companies.I wonder what is the best way to structure the database so that at a later time if the administrator wants to move a user over to another team then it is as easy as just a keystroke.I have created a database that starts with "users", then contains a list of documents that act as a user ID. Inside the collection, it says which company the user belongs to and which team and the ID are equal to the user's login (Authentication) id. I am quite new with databases and firebase, so it would have been nice to know what is the best way to construct such a system.
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/76d32dad-6cd0-449c-854b-c161ab4718ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
First of all, you should create the users keyed by the user id, rather than random document ids. That will help later when you're trying to write security rules and read user accounts.There are two ways to handle the memberships. If the relationship is always 1:1 and that will never change, you could just namespace each group and move users between the groups. So a structure like follows:
/teams/$team/users/$user/teams/$team/widgets/$widgetAnd then you'd simply write security rules to restrict access at the $team level based on whether exists(/databases/$(database)/teams/$(team)/users/$(request.auth.uid));But the more common structure here is probably to do a bit of duplication, as this is a bit more flexible and allows many-to-many relationships:/users/$user/teams (an array of team ids)/teams/$team/members (an array of user ids)And now your teams path is secured with something like request.auth.uid in get(/databases/$(database)/teams/$(team)/members).data;And if you have a user id, you can reverse look up access in the same way: $(teamId) in get(/databases/$(database)/users/$(request.auth.uid)/teams).data;
I hope that helps!
☼, Kato
On Fri, Apr 12, 2019 at 1:21 PM herantd <hera...@gmail.com> wrote:
--Hi,I am currently working on an PWA that will serve as a company portal. The idea is that the user who is employed by company (A) will be part of a team, let's say team: "red". The user who logs in will only have access to the people who are on the same team as this user. For example, company (A) will consist of several teams, and the portal will consist of several companies.I wonder what is the best way to structure the database so that at a later time if the administrator wants to move a user over to another team then it is as easy as just a keystroke.I have created a database that starts with "users", then contains a list of documents that act as a user ID. Inside the collection, it says which company the user belongs to and which team and the ID are equal to the user's login (Authentication) id. I am quite new with databases and firebase, so it would have been nice to know what is the best way to construct such a system.
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/76d32dad-6cd0-449c-854b-c161ab4718ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/04d19a6f-2123-4830-b46e-0080e37db61a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e267872b-3d75-41a3-b38b-1d009980aa0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.