numerus/deploy/logout.sql

28 lines
648 B
MySQL
Raw Normal View History

-- Deploy numerus:logout to pg
-- requires: schema_auth
-- requires: user
begin;
set search_path to numerus, auth, public;
create or replace function logout() returns void as
$$
update "user"
set cookie = default
, cookie_expires_at = default
where email = current_setting('request.user')
$$
language sql
security definer
set search_path to auth, numerus, pg_temp;
comment on function logout() is
'Removes the cookie and its expiry data from the current user, set as request.user setting';
revoke execute on function logout() from public;
grant execute on function logout() to invoicer;
grant execute on function logout() to admin;
commit;