-- Deploy tipus:current_user_cookie to pg
-- requires: roles
-- requires: schema_tipus

begin;

set search_path to tipus;

create or replace function current_user_cookie() returns text as
$$
select current_setting('request.user.cookie', true);
$$
    language sql
    stable;

comment on function current_user_cookie() is
    'Returns the cookie of the current Numerus user';

revoke execute on function current_user_cookie() from public;
grant execute on function current_user_cookie() to guest;
grant execute on function current_user_cookie() to publisher;
grant execute on function current_user_cookie() to admin;

commit;
