summaryrefslogtreecommitdiff
path: root/sql/functions/auth.get_registration_by_hash.sql
blob: 87d622e2c9714e883aa512f737b6c6021e1eb834 (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
drop function auth.get_registration_by_hash (
    p_hash text
);

create or replace function auth.get_registration_by_hash (
    p_hash text
)
returns setof auth.registrations_t
as $$
begin
    return query
    select r.id,
        substring(r.hash::text from 3),
        r.first_name,
        r.last_name,
        r.email,
        r.role_groups,
        r.created,
        (r.created  - (now() - interval '3 days'))::interval as valid_for
    from auth.registrations r
    where r.hash = ('\x' || p_hash)::bytea;

    return;
end;
$$ language plpgsql;