From eeb84725c648af3c8ff5b27595a453b9c8ea3b4a Mon Sep 17 00:00:00 2001 From: patrickwebsdev Date: Thu, 7 Nov 2024 21:56:20 -0300 Subject: [PATCH 1/3] fix: update policy on auth user email only --- ...8005004_add_help_requests_policy_update_with_email.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql diff --git a/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql b/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql new file mode 100644 index 00000000..28d38570 --- /dev/null +++ b/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql @@ -0,0 +1,8 @@ +alter policy "Enable update for users based on email" +on "public"."help_requests" +to public +using ( + ((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email())) +with check ( + ((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email())) +); \ No newline at end of file From c92b62a8036fd5a46665d74c25d3d42b0a2f9e9d Mon Sep 17 00:00:00 2001 From: patrickwebsdev Date: Thu, 7 Nov 2024 22:03:26 -0300 Subject: [PATCH 2/3] fix: supabase update --- ...8005004_add_help_requests_policy_update_with_email.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql b/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql index 28d38570..993bd1f1 100644 --- a/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql +++ b/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql @@ -1,8 +1,6 @@ -alter policy "Enable update for users based on email" -on "public"."help_requests" +alter policy "Enable_update_for_users_based_on_email" +on public.help_requests to public using ( ((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email())) -with check ( - ((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email())) -); \ No newline at end of file +) \ No newline at end of file From ee3965433077d5a547a637fe0e48d98f29874bbf Mon Sep 17 00:00:00 2001 From: patrickwebsdev Date: Thu, 7 Nov 2024 22:06:58 -0300 Subject: [PATCH 3/3] fix: migration --- ...04_add_help_requests_policy_update_with_email.sql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql b/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql index 993bd1f1..d5b5b203 100644 --- a/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql +++ b/supabase/migrations/20241108005004_add_help_requests_policy_update_with_email.sql @@ -1,6 +1,14 @@ +create policy "Enable_update_for_users_based_on_email" +on public.help_requests +for update +to public +using ( + ((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email())) +); + alter policy "Enable_update_for_users_based_on_email" on public.help_requests to public using ( - ((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email())) -) \ No newline at end of file + ((auth.uid() IS NOT NULL) AND ((additional_info ->> 'email'::text) = auth.email())) +);