Modify tablo policies

This commit is contained in:
Arthur Belleville 2025-07-05 18:42:40 +02:00
parent 9b9806c232
commit baee40b32d
No known key found for this signature in database

View file

@ -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);