-- Deploy camper:set_cookie to pg
-- requires: roles
-- requires: schema_public
-- requires: check_cookie

begin;

set search_path to public;

create or replace function set_cookie(input_cookie text, host text) returns void as
$$
select set_config('role', check_cookie(input_cookie, host), false);
$$
language sql
stable;

comment on function set_cookie(text, text) is
'Sets the user information for the cookie and switches to its role';

revoke execute on function set_cookie(text, text) from public;
grant execute on function set_cookie(text, text) to authenticator;

commit;
