Hi guys, I'm having a weird problem with RLS, I ha...
# help
f
Hi guys, I'm having a weird problem with RLS, I have a
recipes
table with a foreign key named
user_id
that is related to
users.uid
. Then I created a policy on top of
recipes
for users to be able to se only what they have created, so I wrote
(auth.uid() = user_id)
. The problem is I can't see anything in my app and the queries always return RLS policy error :/
s
That looks correct, can you check that the
user_id
column inside of the
recipes
table is actually populated
f
Yup, it's populated 😦
s
Delete the policy and add it again and see if that helps
f
Let me try
lol all my policies disappeared
Tried adding but nothing happened o.O
Disabling and enabling made them show up
Re creating the policy didnt work
They still don't show up (ignore the user object, its for debug purposes)
This is the function that I call to list the `recipes`:
Copy code
import { createClient } from '@supabase/supabase-js'

const supabase = createClient(
  import.meta.env.VITE_SUPABASE_URL,
  import.meta.env.VITE_SUPABASE_ANON_KEY
)

export const getAll = async (table) => {
  const { data, error } = await supabase
    .from(table)
    .select('*');

  if (error) {
    console.log(error);
    return false;
  } else {
    return data;
  }
}
s
Inside the SQL editor in the dashboard run
select * from pg_policies
to view all policies
If there are no results, something went wrong with your project
f
They're there, might be a visual bug
So, it seems that none of the policies are working :/
Event the profile ones that were created automatically
s
Oh no, I think something might have gone wrong with your project
Can you open a ticket via the feedback widget in the dashboard about this issue and someone from the Supabase team will look into it. Do note that this might take a little while to get answered.
If you aren't too far into your project, you could create a new project (you can create up to 3 projects per organisation) and recreate everything again and see if you have the same issue.
f
I might plug the code into another project to test
That's a great idea 😄
Besided that, ill open the ticket anyway 🙂
s
Ok thank you
f
Thanks a lot! 😄