Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
20 lines
609 B
PL/PgSQL
20 lines
609 B
PL/PgSQL
create or replace function public.can_request_admin_magic_link(p_email text)
|
|
returns boolean
|
|
language sql stable security definer
|
|
set search_path = ''
|
|
as $$
|
|
select exists (
|
|
select 1
|
|
from public.contacts as contact
|
|
where contact.email = lower(btrim(p_email))
|
|
and (contact.is_admin or contact.email like '%@appe.at')
|
|
and exists (
|
|
select 1 from auth.users as auth_user
|
|
where auth_user.email = contact.email
|
|
)
|
|
);
|
|
$$;
|
|
|
|
revoke all on function public.can_request_admin_magic_link(text) from public;
|
|
grant execute on function public.can_request_admin_magic_link(text) to anon, authenticated;
|