SupabaseS
Supabase2mo ago
Dexter

Cannot access my DB - RLS question

Hello, I have 2 tables in my public schema and both have the following RLS policies:

CREATE POLICY "User can see their own profile only" 
ON public.user
FOR SELECT
TO authenticated
USING ((SELECT auth.uid()) = id);

CREATE POLICY "Users can update their own profile"
ON public.user
FOR UPDATE
TO authenticated                    -- the Postgres Role
USING ((SELECT auth.uid()) = id)      -- checks if the existing row complies with the policy expression
WITH CHECK ((SELECT auth.uid()) = id); -- checks if the new row complies with the policy expression


CREATE POLICY "Users can read any docs"
ON public.docs
FOR SELECT
TO authenticated
USING (true);

CREATE POLICY "Users can insert docs"
ON public.docs
FOR INSERT
TO authenticated
WITH CHECK (submitted_by = (SELECT auth.uid()));

CREATE POLICY "Users update their own docs"
ON public.docs
FOR UPDATE
TO authenticated
USING (submitted_by = (SELECT auth.uid()))
WITH CHECK (submitted_by = (SELECT auth.uid()));

I am logged in, however I cannot access any of the tables using queries from a server component if lets say im on the profile page and I want to fetch user data to populate the page. Are my policies wrong ?
Was this page helpful?