Complete the policy condition to allow access only to the authenticated user.
CREATE POLICY "Allow user access" ON profiles FOR SELECT USING (user_id = [1]);
The function auth.uid() returns the ID of the authenticated user, which is used to restrict access to their own data.
Complete the policy to allow updates only if the authenticated user matches the record owner.
CREATE POLICY "Allow update by owner" ON posts FOR UPDATE USING (owner_id = [1]);
The auth.uid() function returns the authenticated user's ID, ensuring only the owner can update their posts.
Fix the error in the policy condition to correctly check the authenticated user ID.
CREATE POLICY "Allow delete by owner" ON comments FOR DELETE USING (user_id = [1]);
The correct function to get the authenticated user's ID in Supabase policies is auth.uid(). Other options do not return the correct user ID.
Fill both blanks to create a policy allowing inserts only if the authenticated user matches the new record owner.
CREATE POLICY "Allow insert by owner" ON tasks FOR INSERT WITH CHECK (owner_id = [1] AND [2] IS NOT NULL);
old.owner_id which refers to the existing record, not the new one.The policy checks that the owner_id matches the authenticated user ID using auth.uid(), and that the new record's owner_id is not null.
Fill all three blanks to create a policy that allows updates only if the authenticated user owns the record and the new status is 'completed'.
CREATE POLICY "Allow update to completed" ON orders FOR UPDATE USING (user_id = [1]) WITH CHECK (status = [2] AND [3] = 'completed');
auth.uid() for user ID.The policy uses auth.uid() to check ownership, status to check the current status, and new.status to ensure the new status is 'completed'.
