tipus/deploy/current_user_email.sql
jordi fita mas 301195efac Add authentication relations, views, and functions for PostgreSQL
Most of them are exactly the same as we use for Numerus, but with the
main application schema changed to tipus.
2023-06-04 22:45:44 +02:00

25 lines
617 B
PL/PgSQL

-- Deploy tipus:current_user_email to pg
-- requires: roles
-- requires: schema_tipus
begin;
set search_path to tipus;
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 Numerus 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 publisher;
grant execute on function current_user_email() to admin;
commit;