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>
18 lines
570 B
SQL
18 lines
570 B
SQL
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 $function$
|
|
SELECT EXISTS (
|
|
SELECT 1
|
|
FROM public.arc_committee_members acm
|
|
LEFT JOIN auth.users u ON u.id = _user_id
|
|
WHERE acm.association_id = _association_id
|
|
AND acm.is_active = true
|
|
AND (
|
|
acm.user_id = _user_id
|
|
OR (acm.email IS NOT NULL AND u.email IS NOT NULL AND lower(acm.email) = lower(u.email))
|
|
)
|
|
);
|
|
$function$; |