Marketplace inversée (Next.js 16 App Router + Supabase Cloud) : auth, schéma + RLS, publication de besoins avec upload d'images, feed avec filtres, offres, acceptation via RPC, messagerie temps réel, dashboards, et Dockerfile pour déploiement Coolify.
14 lines
780 B
SQL
14 lines
780 B
SQL
-- Faille corrigée : la policy offers_update_own_pending ne limitait pas la
|
|
-- valeur cible de `status`, permettant à un marchand de passer directement sa
|
|
-- propre offre à 'accepted' via un simple PATCH, en contournant accept_offer().
|
|
-- Désormais, un marchand ne peut que rester en 'pending' (édition) ou passer
|
|
-- en 'withdrawn' (retrait volontaire) ; 'accepted'/'rejected' restent
|
|
-- exclusivement gérés par la fonction security definer accept_offer().
|
|
|
|
drop policy if exists "offers_update_own_pending" on public.offers;
|
|
create policy "offers_update_own_pending"
|
|
on public.offers for update
|
|
to authenticated
|
|
using ((select auth.uid()) = merchant_id and status = 'pending')
|
|
with check ((select auth.uid()) = merchant_id and status in ('pending', 'withdrawn'));
|