© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
67 replies
vibegui

Policy to check user belongs to team

Hi, there! Noob question: I want to check if this user belongs to the team which owns the site so the user can select/update etc. I have a Sites table with a "team" property (foreign key to Team id), Teams table, and finally a Members table, with "user_id" and "team". I can't seem to find any good example on creating a policy which looks up "Members" to check whether the currently logged in user belongs to the team which is referenced in the "team" property.

My feeble attempt does not work:

(EXISTS ( SELECT m.user_id,
    m.team
   FROM "Members" m
  WHERE ((m.team = team) AND (m.user_id = uid()))))
(EXISTS ( SELECT m.user_id,
    m.team
   FROM "Members" m
  WHERE ((m.team = team) AND (m.user_id = uid()))))


Do I have to INNER JOIN?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Storage Policy - User Access to File
SupabaseSSupabase / help-and-questions
4y ago
RLS policy for insert to check given column value?
SupabaseSSupabase / help-and-questions
4y ago
Error Inviting User After RLS Policy Query
SupabaseSSupabase / help-and-questions
4y ago
Realtime event is sent to user, even though policy is set
SupabaseSSupabase / help-and-questions
3y ago