Files
thrilltrack-explorer/supabase/migrations/20251004013432_ea896b92-806c-457e-8cf0-6862e11b4925.sql
gpt-engineer-app[bot] d82d5719ec Fix profile viewing policy
2025-10-04 01:34:42 +00:00

13 lines
461 B
SQL

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