Relationship-Based Policies
I’m building an app with a many-to-many between Users and Teams via a TeamMember join resource and need guidance writing two related authorization policies:
I need to allow reading a
These are the relationships defined in this resource:
This is the relationship defined in my
1. TeamMember Resource Policy
Inteam_member.ex I’ve defined:I need to allow reading a
TeamMember record only if the actor is also a member of the same team.These are the relationships defined in this resource:
2. User Resource Policy
Since the above action loads the:user relationship, I also need a similar rule in user.ex. How to allow reading another user only when the actor and the target user share the same team?This is the relationship defined in my
User resource: