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>
28 lines
870 B
PL/PgSQL
28 lines
870 B
PL/PgSQL
CREATE OR REPLACE FUNCTION public.is_arc_committee_member_of_association(_user_id uuid, _association_id uuid)
|
|
RETURNS boolean
|
|
LANGUAGE sql
|
|
STABLE
|
|
SECURITY DEFINER
|
|
SET search_path TO 'public'
|
|
AS $$
|
|
SELECT EXISTS (
|
|
SELECT 1
|
|
FROM public.arc_committee_members acm
|
|
JOIN auth.users u ON lower(u.email) = lower(acm.email)
|
|
WHERE u.id = _user_id
|
|
AND acm.association_id = _association_id
|
|
AND acm.is_active = true
|
|
AND acm.email IS NOT NULL
|
|
);
|
|
$$;
|
|
|
|
DROP POLICY IF EXISTS "ARC committee members can view association ARC applications" ON public.arc_applications;
|
|
|
|
CREATE POLICY "ARC committee members can view association ARC applications"
|
|
ON public.arc_applications
|
|
FOR SELECT
|
|
TO authenticated
|
|
USING (
|
|
public.has_role(auth.uid(), 'arc_member'::public.app_role)
|
|
AND public.is_arc_committee_member_of_association(auth.uid(), association_id)
|
|
); |