-- Corrections suite au linter de sécurité Supabase (get_advisors) après 0002. -- 1. Bucket public : pas besoin d'une policy SELECT (elle permet le listing -- complet du bucket, superflu — l'URL publique fonctionne sans RLS). drop policy if exists "need_images_bucket_read" on storage.objects; -- 2. handle_new_user() ne doit être invocable que par le trigger, pas en RPC public. revoke execute on function public.handle_new_user() from public, anon, authenticated; -- 3. accept_offer() : anon n'a aucune raison de l'appeler (auth.uid() sera -- toujours null pour lui, mais autant réduire la surface d'API exposée). revoke execute on function public.accept_offer(uuid) from anon; -- 4. offer-images : resserrer la lecture aux seuls participants (marchand -- auteur de l'offre, ou auteur du besoin concerné) au lieu de "tout -- utilisateur connecté". drop policy if exists "offer_images_bucket_read" on storage.objects; create policy "offer_images_bucket_read" on storage.objects for select to authenticated using ( bucket_id = 'offer-images' and exists ( select 1 from public.offer_images oi join public.offers o on o.id = oi.offer_id where oi.storage_path = storage.objects.name and ( o.merchant_id = auth.uid() or exists (select 1 from public.needs n where n.id = o.need_id and n.author_id = auth.uid()) ) ) );