Fix profile viewing policy

This commit is contained in:
gpt-engineer-app[bot]
2025-10-04 01:34:42 +00:00
parent 756d6a5300
commit d82d5719ec

View File

@@ -0,0 +1,13 @@
-- Drop the restrictive authenticated-only policy
DROP POLICY IF EXISTS "Authenticated users can view profiles" ON public.profiles;
-- Create a new policy that allows both anonymous and authenticated users to view public profiles
CREATE POLICY "Public can view non-banned public profiles"
ON public.profiles
FOR SELECT
TO anon, authenticated
USING (
(auth.uid() = user_id)
OR is_moderator(auth.uid())
OR ((privacy_level = 'public') AND (NOT banned))
);