From 648c903b8019cdbbd6c35fecaf43d2d2520a7a08 Mon Sep 17 00:00:00 2001 From: rpm-mcarman <65228808+rpm-mcarman@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:19:41 -0400 Subject: [PATCH] Changed default admin role to upload to server --- app/api/security/defalutadminapi.json | 160 ++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 21 deletions(-) diff --git a/app/api/security/defalutadminapi.json b/app/api/security/defalutadminapi.json index df5f36b..b90f6d3 100644 --- a/app/api/security/defalutadminapi.json +++ b/app/api/security/defalutadminapi.json @@ -4,6 +4,14 @@ { "type": "text", "name": "id" + }, + { + "type": "text", + "name": "sort" + }, + { + "type": "text", + "name": "dir" } ] }, @@ -39,7 +47,15 @@ "column": "lastname" } ], - "params": [], + "params": [ + { + "operator": "equal", + "type": "expression", + "name": ":P1", + "value": "{{$_GET.id}}", + "test": "" + } + ], "table": { "name": "users" }, @@ -49,22 +65,21 @@ "condition": "AND", "rules": [ { - "id": "users.email", - "field": "users.email", - "type": "string", + "id": "users.id", + "field": "users.id", + "type": "double", "operator": "equal", - "value": "admin@prelub.com", + "value": "{{$_GET.id}}", "data": { "table": "users", - "column": "email", - "type": "text", + "column": "id", + "type": "number", "columnObj": { - "type": "string", - "maxLength": 255, - "primary": false, + "type": "increments", + "primary": true, "unique": false, - "nullable": true, - "name": "email" + "nullable": false, + "name": "id" } }, "operation": "=" @@ -73,7 +88,7 @@ "conditional": null, "valid": true }, - "query": "select `id`, `email`, `pwd`, `firstname`, `lastname` from `users` where `users`.`email` = ?" + "query": "select `id`, `email`, `pwd`, `firstname`, `lastname` from `users` where `users`.`id` = ?" } }, "output": true, @@ -106,7 +121,7 @@ "module": "core", "action": "condition", "options": { - "if": "{{!gettheuser}}", + "if": "{{gettheuser}}", "then": { "steps": [ { @@ -237,15 +252,118 @@ "outputType": "object" }, { - "name": "addrole", - "module": "api", - "action": "send", + "name": "query", + "module": "dbconnector", + "action": "select", "options": { - "url": "{{$_ENV.API_BASEURL+'xuserroles/add/'+gettheuser.id+'/1'}}", - "method": "POST", - "dataType": "json" + "connection": "authdb", + "sql": { + "type": "select", + "columns": [ + { + "table": "xuserrole", + "column": "roleid" + } + ], + "params": [ + { + "operator": "equal", + "type": "expression", + "name": ":P1", + "value": "{{$_GET.id}}", + "test": "" + } + ], + "table": { + "name": "xuserrole" + }, + "primary": "id", + "joins": [], + "wheres": { + "condition": "AND", + "rules": [ + { + "id": "xuserrole.userid", + "field": "xuserrole.userid", + "type": "double", + "operator": "equal", + "value": "{{$_GET.id}}", + "data": { + "table": "xuserrole", + "column": "userid", + "type": "number", + "columnObj": { + "type": "integer", + "primary": false, + "unique": false, + "nullable": true, + "name": "userid" + } + }, + "operation": "=" + } + ], + "conditional": null, + "valid": true + }, + "query": "select `roleid` from `xuserrole` where `xuserrole`.`userid` = ?" + } + }, + "output": true, + "meta": [ + { + "type": "number", + "name": "roleid" + } + ], + "outputType": "array" + }, + { + "name": "repeat", + "module": "core", + "action": "repeat", + "options": { + "outputFilter": "exclude", + "repeat": "{{query}}", + "outputFields": [], + "exec": { + "steps": { + "name": "addrole", + "module": "api", + "action": "send", + "options": { + "url": "{{$_ENV.API_BASEURL+'xuserroles/add/'+gettheuser.id+'/'+roleid}}", + "method": "POST", + "dataType": "json" + }, + "output": true + } + } }, - "output": true + "output": true, + "meta": [ + { + "name": "$index", + "type": "number" + }, + { + "name": "$number", + "type": "number" + }, + { + "name": "$name", + "type": "text" + }, + { + "name": "$value", + "type": "object" + }, + { + "name": "roleid", + "type": "number" + } + ], + "outputType": "array" } ] }