feat: add backend pricing calculation RPC and refactor create_lead function
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -65,9 +65,7 @@ grant anon, authenticated, service_role to supabase_storage_admin;
|
||||
|
||||
grant select on storage.buckets to anon, authenticated;
|
||||
grant all on storage.buckets to service_role;
|
||||
grant select on storage.objects to anon;
|
||||
grant insert on storage.objects to anon;
|
||||
grant update on storage.objects to anon;
|
||||
grant select, insert, update, delete on storage.objects to authenticated;
|
||||
grant all on storage.objects to service_role;
|
||||
|
||||
@@ -110,27 +108,19 @@ drop policy if exists "custdocs_public_upload" on storage.objects;
|
||||
drop policy if exists "custdocs_public_upsert_update" on storage.objects;
|
||||
drop policy if exists "custdocs_admin_read" on storage.objects;
|
||||
drop policy if exists "custdocs_admin_delete" on storage.objects;
|
||||
drop policy if exists "custdocs_admin_insert" on storage.objects;
|
||||
|
||||
-- Anon can upload (insert) during booking flow
|
||||
-- Anon can only INSERT (upload) during booking flow — no SELECT/UPDATE/DELETE
|
||||
create policy "custdocs_anon_upload"
|
||||
on storage.objects for insert to anon
|
||||
with check (bucket_id = 'customer-documents');
|
||||
|
||||
-- Anon needs SELECT + UPDATE for x-upsert to work (Supabase storage requirement)
|
||||
create policy "custdocs_anon_select"
|
||||
on storage.objects for select to anon
|
||||
using (bucket_id = 'customer-documents');
|
||||
|
||||
create policy "custdocs_anon_update"
|
||||
on storage.objects for update to anon
|
||||
using (bucket_id = 'customer-documents')
|
||||
with check (bucket_id = 'customer-documents');
|
||||
|
||||
-- Authenticated admins can read/delete
|
||||
-- Authenticated admins can read (view documents)
|
||||
create policy "custdocs_admin_read"
|
||||
on storage.objects for select to authenticated
|
||||
using (bucket_id = 'customer-documents');
|
||||
|
||||
create policy "custdocs_admin_delete"
|
||||
on storage.objects for delete to authenticated
|
||||
using (bucket_id = 'customer-documents');
|
||||
-- Authenticated admins can upload new documents
|
||||
create policy "custdocs_admin_insert"
|
||||
on storage.objects for insert to authenticated
|
||||
with check (bucket_id = 'customer-documents');
|
||||
|
||||
Reference in New Issue
Block a user