diff options
| author | ckonstanski <carlos.konstanski@olo.com> | 2024-05-25 18:03:25 -0600 |
|---|---|---|
| committer | ckonstanski <carlos.konstanski@olo.com> | 2024-05-25 18:03:25 -0600 |
| commit | b8423f4d05c75094b7b9d09c6f0bb353acc9be1c (patch) | |
| tree | 3732f71f84191b26f038130c2220fb502d738251 /sql/functions/auth.insert_registration.sql | |
initial commit
Diffstat (limited to 'sql/functions/auth.insert_registration.sql')
| -rw-r--r-- | sql/functions/auth.insert_registration.sql | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sql/functions/auth.insert_registration.sql b/sql/functions/auth.insert_registration.sql new file mode 100644 index 0000000..0f0b73d --- /dev/null +++ b/sql/functions/auth.insert_registration.sql @@ -0,0 +1,42 @@ +drop function auth.insert_registration ( + p_first_name character varying, + p_last_name character varying, + p_email character varying, + p_role_groups text +); + +create or replace function auth.insert_registration ( + p_first_name character varying, + p_last_name character varying, + p_email character varying, + p_role_groups text +) +returns bigint +as $$ +declare + l_id bigint; +begin + insert into auth.registrations ( + hash, + first_name, + last_name, + email, + role_groups + ) values ( + digest(concat(cast(current_timestamp as text), random()::text), 'sha512'), + p_first_name, + p_last_name, + p_email, + p_role_groups + ); + + select id into l_id + from auth.registrations + where first_name = p_first_name + and last_name = p_last_name + and email = p_email + and role_groups = p_role_groups; + + return l_id; +end; +$$ language plpgsql; |
