Mercurial > gemma
comparison schema/manage_users.sql @ 185:a9d9c2b1d08c
Add database function to create role and user profile
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 19 Jul 2018 16:37:52 +0200 |
parents | |
children | 5dc8e734487a |
comparison
equal
deleted
inserted
replaced
184:bc7829defa99 | 185:a9d9c2b1d08c |
---|---|
1 -- | |
2 -- Functions encapsulating user management functionality and | |
3 -- exposing it to privileged users | |
4 -- | |
5 | |
6 CREATE OR REPLACE FUNCTION create_user( | |
7 userrole varchar, | |
8 username user_profiles.username%TYPE, | |
9 pw varchar, | |
10 country user_profiles.country%TYPE, | |
11 map_extent user_profiles.map_extent%TYPE, | |
12 email_adress user_profiles.email_adress%TYPE | |
13 ) | |
14 RETURNS void | |
15 AS $$ | |
16 BEGIN | |
17 INSERT INTO user_profiles VALUES ( | |
18 username, country, map_extent, email_adress); | |
19 EXECUTE format( | |
20 'CREATE ROLE %I IN ROLE %I LOGIN PASSWORD %L', username, userrole, pw); | |
21 END; | |
22 $$ | |
23 LANGUAGE plpgsql; |