Access user_metadata property from JWT in RLS

Hi, I've been reading up on the docs and even using ChatGPT to try and find out how to get RLS working for my tables.

I have table
data
that relies on a table current_members for whether or not they can access whatever is in
data
. The problem is, current_members has a user_id column that is from the user's discord id, not the inbuilt id, so I can't go auth.uid(), instead I have to get it from the auth JWT:
(EXISTS ( SELECT 1
   FROM current_members
  WHERE ((current_members.user_id)::text = ((auth.jwt() -> 'user_metadata'::text) ->> 'sub'::text))))

I'm fairly sure I've got the syntax for the JSONB wrong - would very much appreciate the help.
Using Row Level Security with Supabase Auth.
Was this page helpful?