numerus/deploy/find_user_role.sql
jordi fita mas 45439c8559 Remove the revocation of all function executions
I need to execute some functions in public for citext, such as
texticregexeq, or guest users would not be able to login.
2023-01-17 13:05:58 +01:00

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;