Files
acmcc/supabase/migrations/20260410204647_0f91b6db-b71d-4b71-a7dc-d5496e554de6.sql
2026-06-01 20:19:26 -04:00

21 lines
967 B
SQL

-- Fix anon SELECT: restrict to rows matching a vote_token or access_code filter
DROP POLICY IF EXISTS "Anon can select own voter record by token" ON public.election_eligible_voters;
CREATE POLICY "Anon can select own voter record by token" ON public.election_eligible_voters
FOR SELECT TO anon
USING (
vote_token::text = current_setting('request.headers', true)::json->>'x-vote-token'
OR access_code = current_setting('request.headers', true)::json->>'x-access-code'
);
-- Fix anon UPDATE: restrict to rows matching vote_token filter
DROP POLICY IF EXISTS "Anon can update voted status by token" ON public.election_eligible_voters;
CREATE POLICY "Anon can update voted status by token" ON public.election_eligible_voters
FOR UPDATE TO anon
USING (
vote_token::text = current_setting('request.headers', true)::json->>'x-vote-token'
)
WITH CHECK (
vote_token::text = current_setting('request.headers', true)::json->>'x-vote-token'
);