25 lines
556 B
PL/PgSQL
25 lines
556 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';
|
|
|
|
commit;
|