numerus/deploy/find_user_role.sql

27 lines
625 B
PL/PgSQL

-- Deploy numerus:find_user_role to pg
-- requires: schema_auth
-- requires: user
-- requires: email
begin;
set search_path to auth, numerus, public;
create or replace function find_user_role(email email, password text) returns name
as
$$
select role
from auth."user"
where "user".email = find_user_role.email
and "user".password = crypt(find_user_role.password, "user".password);
$$
language sql
stable;
comment on function find_user_role(email, text) is
'Return the database role assigned to the user with the given email and password';
revoke execute on function find_user_role(email, text) from public;
commit;