mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
183fe0a93c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
21 lines
967 B
SQL
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'
|
|
);
|