Recently wanted to add a feature to support multiple teams in my app without seeing each others’ data. Able to get it working for most Data Types by adding a “Team” field to each data type and setting privacy rules there, but getting stuck on privacy for viewing the email field on a User.
App Background:
A Question + Answer app, where a user can create a question with a title+description, then users can submit answers to that question. Users can also be a member of one or more teams, and each team has admins that can invite and remove users from the team. It gets more complicated than your generic “learn Bubble” tutorial because users can be members of multiple teams AND users can be admins of one or more teams, and I want to set privacy rules based on those two lists.
What I’ve got so far:
- I currently have these four data types: User, Question, Answer, & Team
- User has a Team_Viewer field which is a list of Teams they can view.
- User also has a Team_Admin field which is a list of Teams where they are an admin.
- Question and Answer each has a Team field, linking to a single Team. I use a Privacy Rule to check if
Current User's Team_Viewer contains This Question's Team
in order to determine whether fields are viewable. (I also have a rule that ifThis Question's Team is empty
the fields are viewable, essentially I treat a blank field as saying it is “public”). Ditto for Answer.
So far so good! Where it gets stuck is the User data type. Since the Team_Viewer and Team_Admin fields are both lists I haven’t been able to get a working logic - it just asks for endless contains if I click More below:
Two ways out I see are:
- Add an Admin yes/no field to User, set a privacy rule for viewing user email there, then filter out further on the front end based on Team_Admin. But I don’t really like the idea of Admins on one team being able to see the email address of users not in their team.
- Create a new Data Type that has the list of Users with their email addresses for each Team they are on, then reference this new Data Type where I want to show the email address and set privacy rules on it.
Option 2 is fine but was hoping there was a more elegant solution / best practice someone might know of!
For reference, the best post I found on this so far were the best practices shared in Best Practice Privacy Structure for Multi-Tenant SAAS - #2 by StevenM as well as this helpful Youtube video: https://www.youtube.com/watch?v=_DKEXFZJU-M . I appreciate your help!