camper/deploy/current_user_email.sql

25 lines
606 B
PL/PgSQL

-- Deploy camper:current_user_email to pg
-- requires: roles
-- requires: schema_camper
begin;
set search_path to camper;
create or replace function current_user_email() returns text as
$$
select current_setting('request.user.email', true);
$$
language sql
stable;
comment on function current_user_email() is
'Returns the email of the current Camper user';
revoke execute on function current_user_email() from public;
grant execute on function current_user_email() to guest;
grant execute on function current_user_email() to employee;
grant execute on function current_user_email() to admin;
commit;