camper/deploy/build_cookie.sql

26 lines
802 B
MySQL
Raw Normal View History

-- Deploy camper:build_cookie to pg
-- requires: roles
-- requires: schema_camper
-- requires: current_user_email
-- requires: current_user_cookie
begin;
set search_path to camper, public;
create or replace function build_cookie(user_email email default null, user_cookie text default null) returns text as
$$
select coalesce(user_cookie, current_user_cookie()) || '/' || coalesce(user_email, current_user_email());
$$
language sql
stable;
revoke execute on function build_cookie(email, text) from public;
grant execute on function build_cookie(email, text) to employee;
grant execute on function build_cookie(email, text) to admin;
comment on function build_cookie(email, text) is
'Build the cookie to send to the users browser, either for the given values or for the current user.';
commit;