summaryrefslogtreecommitdiff
path: root/sql/functions/auth.get_registration_by_id.sql
blob: dc9fdc103d76f64b5de1b935942efe78367e0f1d (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_id (
    p_id bigint
);

create or replace function auth.get_registration_by_id (
    p_id bigint
)
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.id = p_id;

    return;
end;
$$ language plpgsql;