Files
acmcc/supabase/migrations/20260507173932_c1edf906-305f-4585-91e0-3c5b811b84ad.sql
T
2026-06-01 20:19:26 -04:00

12 lines
299 B
PL/PgSQL

CREATE OR REPLACE FUNCTION public.lookup_email_by_username(_username text)
RETURNS text
LANGUAGE sql
STABLE SECURITY DEFINER
SET search_path TO 'public'
AS $$
SELECT u.email
FROM public.profiles p
JOIN auth.users u ON u.id = p.user_id
WHERE lower(p.username) = lower(_username)
LIMIT 1
$$;