summaryrefslogtreecommitdiff
path: root/sql/functions/auth.get_active_user_by_username_pwd.sql
blob: 26f926c523abdfc49826a9f3d867a629a263bd13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
drop function auth.get_active_user_by_username_pwd (
    p_username character varying,
    p_pwd character varying
);

create or replace function auth.get_active_user_by_username_pwd (
    p_username character varying,
    p_pwd character varying
)
returns setof auth.users
as $$
begin
    return query
    select u.id,
        u.username,
        u.pwd,
        u.first_name,
        u.last_name,
        u.email,
        u.phone,
        u.active,
        u.created
    from auth.users u
    where u.username = p_username
        and u.pwd = digest(p_pwd, 'sha512')
        and u.active = true;

    return;
end;
$$ language plpgsql;a