Created
November 9, 2016 16:17
-
-
Save dmytro-ndp/bfa66e7ab708ee1055f6e9113fc64cb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE FUNCTION add_system_permission(id VARCHAR, permissions VARCHAR | |
| ) RETURNS DECIMAL AS ' | |
| INSERT INTO systempermissions_actions(systempermissions_id, actions) | |
| SELECT s.id, $2 | |
| FROM systempermissions s | |
| WHERE | |
| EXISTS (SELECT userid FROM systempermissions WHERE userid = $1) | |
| AND | |
| NOT EXISTS (SELECT systempermissions_id | |
| FROM systempermissions_actions | |
| WHERE systempermissions_id = s.id AND actions = $2); | |
| SELECT 1.0 | |
| ' LANGUAGE SQL; | |
| CREATE OR REPLACE FUNCTION get_user_identifier( | |
| email VARCHAR | |
| ) RETURNS VARCHAR AS ' | |
| SELECT id FROM usr WHERE email = $1 | |
| ' LANGUAGE SQL; | |
| SELECT add_system_permission(get_user_identifier('admin@codenvy.onprem'), 'manageCodenvy') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment