From baee40b32db255839283222a57d5636eeece1c7f Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Sat, 5 Jul 2025 18:42:40 +0200 Subject: [PATCH] Modify tablo policies --- sql/08_create_tablos_table.sql | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sql/08_create_tablos_table.sql b/sql/08_create_tablos_table.sql index 6d3fd76..22da24d 100644 --- a/sql/08_create_tablos_table.sql +++ b/sql/08_create_tablos_table.sql @@ -19,17 +19,24 @@ ALTER TABLE tablos ENABLE ROW LEVEL SECURITY; -- Create policy to allow users to see only their own tablos CREATE POLICY "Users can view tablos they have access to" ON tablos - FOR SELECT USING ( + FOR SELECT + TO authenticated + USING ( (SELECT auth.uid()) = owner_id OR EXISTS ( - SELECT 1 FROM tablo_access WHERE tablo_id = tablos.id AND user_id = auth.uid() + SELECT 1 FROM tablo_access WHERE tablo_id = tablos.id AND user_id = (SELECT auth.uid()) ) ); -- Create policy to allow users to insert their own tablos CREATE POLICY "Users can insert own tablos" ON tablos - FOR INSERT WITH CHECK (auth.uid() = owner_id); + FOR INSERT + TO authenticated + WITH CHECK ((SELECT auth.uid()) = owner_id); --- Create policy to allow users to update their own tablos +-- -- Create policy to allow users to update their own tablos CREATE POLICY "Users can update own tablos" ON tablos - FOR UPDATE USING (auth.uid() = owner_id); + FOR UPDATE + TO authenticated + USING ((SELECT auth.uid()) = owner_id) + WITH CHECK ((SELECT auth.uid()) = owner_id); \ No newline at end of file