Fix security vulnerability

This commit is contained in:
gpt-engineer-app[bot]
2025-10-26 15:05:22 +00:00
parent f9228d5024
commit 47ac10da2f
3 changed files with 8 additions and 5 deletions

View File

@ -44,7 +44,7 @@ const Index = () => {
const fetchSignatureCount = async () => {
const { count } = await supabase
.from('petition_signatures')
.from('petition_signatures_public')
.select('*', { count: 'exact', head: true });
setSignatureCount(count || 0);

View File

@ -47,16 +47,16 @@ const Testimonies = () => {
const fetchSignatures = async () => {
try {
// Get total count
// Get total count from public view (emails hidden)
const { count } = await supabase
.from('petition_signatures')
.from('petition_signatures_public')
.select('*', { count: 'exact', head: true });
setTotalCount(count || 0);
// Get signatures with comments
// Get signatures with comments from public view (emails hidden)
const { data, error } = await supabase
.from('petition_signatures')
.from('petition_signatures_public')
.select('*')
.not('comment', 'is', null)
.order('created_at', { ascending: false });

View File

@ -0,0 +1,3 @@
-- Fix the security definer view by enabling security invoker mode
-- This ensures the view respects RLS policies of the querying user
ALTER VIEW public.petition_signatures_public SET (security_invoker = on);