Fixing template
This commit is contained in:
@@ -9,23 +9,17 @@ RETURNS <%= return_type %> AS $$
|
|||||||
DECLARE
|
DECLARE
|
||||||
<%= return_declaration if not multi_row %>
|
<%= return_declaration if not multi_row %>
|
||||||
<%= user_org_declaration %>
|
<%= user_org_declaration %>
|
||||||
<% unless superuser_function? -%>
|
<% unless superuser_function? -%>appname text;
|
||||||
appname TEXT;
|
apikey_permissions json;<% end %>
|
||||||
apikey_permissions JSON;
|
|
||||||
<% end %>
|
|
||||||
BEGIN
|
BEGIN
|
||||||
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
||||||
RAISE EXCEPTION 'The api_key must be provided';
|
RAISE EXCEPTION 'The api_key must be provided';
|
||||||
END IF;
|
END IF;
|
||||||
<% unless superuser_function? -%>
|
<% unless superuser_function? -%>SELECT u, o, a, p INTO username, orgname, appname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, a text, p json);
|
||||||
SELECT u, o, a, p INTO username, orgname, appname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, a text, p json);
|
<% if requires_permission %>IF NOT apikey_permissions::jsonb ? '<%= permission_name %>' THEN
|
||||||
<% if requires_permission %>
|
|
||||||
IF NOT apikey_permissions::jsonb ? '<%= permission_name %>' THEN
|
|
||||||
RAISE EXCEPTION '<%= permission_error %>';
|
RAISE EXCEPTION '<%= permission_error %>';
|
||||||
END IF;
|
END IF;
|
||||||
<% else %>
|
<% else %>SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text);<% end %><% end %>
|
||||||
SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text);
|
|
||||||
<% end %><% end %>
|
|
||||||
-- JSON value stored "" is taken as literal
|
-- JSON value stored "" is taken as literal
|
||||||
IF username IS NULL OR username = '' OR username = '""' THEN
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
||||||
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
||||||
|
|||||||
Reference in New Issue
Block a user