diff --git a/composer.lock b/composer.lock index 2a27d7605..30608f63e 100644 --- a/composer.lock +++ b/composer.lock @@ -54,16 +54,16 @@ }, { "name": "cakephp/cakephp", - "version": "3.8.7", + "version": "3.8.8", "source": { "type": "git", "url": "https://github.com/cakephp/cakephp.git", - "reference": "bf96319a3688c191742d4a3a1680740abef1b371" + "reference": "d01515c90646590183e34bc40cf8d9911f88ef5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/cakephp/zipball/bf96319a3688c191742d4a3a1680740abef1b371", - "reference": "bf96319a3688c191742d4a3a1680740abef1b371", + "url": "https://api.github.com/repos/cakephp/cakephp/zipball/d01515c90646590183e34bc40cf8d9911f88ef5c", + "reference": "d01515c90646590183e34bc40cf8d9911f88ef5c", "shasum": "" }, "require": { @@ -139,7 +139,7 @@ "rapid-development", "validation" ], - "time": "2019-12-08T02:59:05+00:00" + "time": "2019-12-29T02:09:22+00:00" }, { "name": "cakephp/chronos", @@ -252,21 +252,21 @@ }, { "name": "cakephp/plugin-installer", - "version": "1.1.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/cakephp/plugin-installer.git", - "reference": "af9711ee5dfbe62a76e8aa86cb348895fab23b50" + "reference": "3be2ea116603341b196592053e973f4abe71e8b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/plugin-installer/zipball/af9711ee5dfbe62a76e8aa86cb348895fab23b50", - "reference": "af9711ee5dfbe62a76e8aa86cb348895fab23b50", + "url": "https://api.github.com/repos/cakephp/plugin-installer/zipball/3be2ea116603341b196592053e973f4abe71e8b2", + "reference": "3be2ea116603341b196592053e973f4abe71e8b2", "shasum": "" }, "require-dev": { "cakephp/cakephp-codesniffer": "dev-master", - "composer/composer": "1.0.*@dev", + "composer/composer": "^1.0", "phpunit/phpunit": "^4.8|^5.7|^6.0" }, "type": "composer-installer", @@ -275,7 +275,7 @@ }, "autoload": { "psr-4": { - "Cake\\Composer\\": "src" + "Cake\\Composer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -285,11 +285,11 @@ "authors": [ { "name": "CakePHP Community", - "homepage": "http://cakephp.org" + "homepage": "https://cakephp.org" } ], "description": "A composer installer for CakePHP 3.0+ plugins.", - "time": "2019-07-25T15:43:38+00:00" + "time": "2019-11-12T10:21:19+00:00" }, { "name": "google/protobuf", @@ -431,16 +431,16 @@ }, { "name": "paragonie/sodium_compat", - "version": "v1.12.1", + "version": "v1.12.2", "source": { "type": "git", "url": "https://github.com/paragonie/sodium_compat.git", - "reference": "063cae9b3a7323579063e7037720f5b52b56c178" + "reference": "3b953109fdfc821c1979bc829c8b7421721fef82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/063cae9b3a7323579063e7037720f5b52b56c178", - "reference": "063cae9b3a7323579063e7037720f5b52b56c178", + "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/3b953109fdfc821c1979bc829c8b7421721fef82", + "reference": "3b953109fdfc821c1979bc829c8b7421721fef82", "shasum": "" }, "require": { @@ -509,7 +509,7 @@ "secret-key cryptography", "side-channel resistant" ], - "time": "2019-11-07T17:07:24+00:00" + "time": "2019-12-30T03:11:08+00:00" }, { "name": "psr/container", @@ -707,23 +707,21 @@ }, { "name": "robmorgan/phinx", - "version": "0.11.3", + "version": "0.11.4", "source": { "type": "git", "url": "https://github.com/cakephp/phinx.git", - "reference": "3c6a171b0455225cf42716dc4864feb620da716f" + "reference": "10e8c3f6b09111f4c0ef128d5a43375e15286cc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/phinx/zipball/3c6a171b0455225cf42716dc4864feb620da716f", - "reference": "3c6a171b0455225cf42716dc4864feb620da716f", + "url": "https://api.github.com/repos/cakephp/phinx/zipball/10e8c3f6b09111f4c0ef128d5a43375e15286cc5", + "reference": "10e8c3f6b09111f4c0ef128d5a43375e15286cc5", "shasum": "" }, "require": { - "cakephp/collection": "^3.6", - "cakephp/core": "^3.6", - "cakephp/database": "^3.6", - "cakephp/datasource": "^3.6", + "cakephp/collection": "^3.7", + "cakephp/database": "^3.7", "php": ">=5.6", "symfony/config": "^3.4|^4.0|^5.0", "symfony/console": "^3.4|^4.0|^5.0", @@ -780,20 +778,20 @@ "migrations", "phinx" ], - "time": "2019-12-12T16:53:38+00:00" + "time": "2019-12-24T23:43:31+00:00" }, { "name": "symfony/config", - "version": "v5.0.1", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "c0773efcc2c940ffbc4c34a0dba2836f2cf6dc9c" + "reference": "7f930484966350906185ba0a604728f7898b7ba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/c0773efcc2c940ffbc4c34a0dba2836f2cf6dc9c", - "reference": "c0773efcc2c940ffbc4c34a0dba2836f2cf6dc9c", + "url": "https://api.github.com/repos/symfony/config/zipball/7f930484966350906185ba0a604728f7898b7ba0", + "reference": "7f930484966350906185ba0a604728f7898b7ba0", "shasum": "" }, "require": { @@ -844,20 +842,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2019-12-01T10:51:15+00:00" + "time": "2019-12-18T13:50:31+00:00" }, { "name": "symfony/console", - "version": "v4.4.1", + "version": "v4.4.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "f0aea3df20d15635b3cb9730ca5eea1c65b7f201" + "reference": "82437719dab1e6bdd28726af14cb345c2ec816d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f0aea3df20d15635b3cb9730ca5eea1c65b7f201", - "reference": "f0aea3df20d15635b3cb9730ca5eea1c65b7f201", + "url": "https://api.github.com/repos/symfony/console/zipball/82437719dab1e6bdd28726af14cb345c2ec816d0", + "reference": "82437719dab1e6bdd28726af14cb345c2ec816d0", "shasum": "" }, "require": { @@ -920,11 +918,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-12-01T10:06:17+00:00" + "time": "2019-12-17T10:32:23+00:00" }, { "name": "symfony/filesystem", - "version": "v4.4.1", + "version": "v4.4.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", @@ -1207,16 +1205,16 @@ }, { "name": "symfony/yaml", - "version": "v5.0.1", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "51b684480184fa767b97e28eaca67664e48dd3e9" + "reference": "847661e77afa48d99ecfa508e8b60f0b029a19c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/51b684480184fa767b97e28eaca67664e48dd3e9", - "reference": "51b684480184fa767b97e28eaca67664e48dd3e9", + "url": "https://api.github.com/repos/symfony/yaml/zipball/847661e77afa48d99ecfa508e8b60f0b029a19c0", + "reference": "847661e77afa48d99ecfa508e8b60f0b029a19c0", "shasum": "" }, "require": { @@ -1262,7 +1260,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2019-11-18T17:27:11+00:00" + "time": "2019-12-10T11:06:55+00:00" }, { "name": "zendframework/zend-diactoros", @@ -1324,6 +1322,7 @@ "psr", "psr-7" ], + "abandoned": "laminas/laminas-diactoros", "time": "2019-08-06T17:53:53+00:00" } ], @@ -1447,16 +1446,16 @@ }, { "name": "asm89/twig-cache-extension", - "version": "1.3.2", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/asm89/twig-cache-extension.git", - "reference": "630ea7abdc3fc62ba6786c02590a1560e449cf55" + "reference": "13787226956ec766f4770722082288097aebaaf3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/630ea7abdc3fc62ba6786c02590a1560e449cf55", - "reference": "630ea7abdc3fc62ba6786c02590a1560e449cf55", + "url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/13787226956ec766f4770722082288097aebaaf3", + "reference": "13787226956ec766f4770722082288097aebaaf3", "shasum": "" }, "require": { @@ -1464,7 +1463,8 @@ "twig/twig": "^1.0|^2.0" }, "require-dev": { - "doctrine/cache": "~1.0" + "doctrine/cache": "~1.0", + "phpunit/phpunit": "^5.0 || ^4.8.10" }, "suggest": { "psr/cache-implementation": "To make use of PSR-6 cache implementation via PsrCacheAdapter." @@ -1472,7 +1472,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1497,7 +1497,7 @@ "extension", "twig" ], - "time": "2017-01-10T22:04:15+00:00" + "time": "2020-01-01T20:47:37+00:00" }, { "name": "cakephp/bake", @@ -1654,16 +1654,16 @@ }, { "name": "composer/ca-bundle", - "version": "1.2.5", + "version": "1.2.6", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "62e8fc2dc550e5d6d8c9360c7721662670f58149" + "reference": "47fe531de31fca4a1b997f87308e7d7804348f7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/62e8fc2dc550e5d6d8c9360c7721662670f58149", - "reference": "62e8fc2dc550e5d6d8c9360c7721662670f58149", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/47fe531de31fca4a1b997f87308e7d7804348f7e", + "reference": "47fe531de31fca4a1b997f87308e7d7804348f7e", "shasum": "" }, "require": { @@ -1706,20 +1706,20 @@ "ssl", "tls" ], - "time": "2019-12-11T14:44:42+00:00" + "time": "2020-01-13T10:02:55+00:00" }, { "name": "composer/composer", - "version": "1.9.1", + "version": "1.9.2", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "bb01f2180df87ce7992b8331a68904f80439dd2f" + "reference": "7a04aa0201ddaa0b3cf64d41022bd8cdcd7fafeb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/bb01f2180df87ce7992b8331a68904f80439dd2f", - "reference": "bb01f2180df87ce7992b8331a68904f80439dd2f", + "url": "https://api.github.com/repos/composer/composer/zipball/7a04aa0201ddaa0b3cf64d41022bd8cdcd7fafeb", + "reference": "7a04aa0201ddaa0b3cf64d41022bd8cdcd7fafeb", "shasum": "" }, "require": { @@ -1786,28 +1786,27 @@ "dependency", "package" ], - "time": "2019-11-01T16:20:17+00:00" + "time": "2020-01-14T15:30:32+00:00" }, { "name": "composer/semver", - "version": "1.5.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e" + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/46d9139568ccb8d9e7cdd4539cab7347568a5e2e", - "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e", + "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5", - "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" + "phpunit/phpunit": "^4.5 || ^5.0.5" }, "type": "library", "extra": { @@ -1848,7 +1847,7 @@ "validation", "versioning" ], - "time": "2019-03-19T17:25:45+00:00" + "time": "2020-01-13T12:06:48+00:00" }, { "name": "composer/spdx-licenses", @@ -2674,16 +2673,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", + "version": "4.3.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/da3fd972d6bafd628114f7e7e036f45944b62e9c", + "reference": "da3fd972d6bafd628114f7e7e036f45944b62e9c", "shasum": "" }, "require": { @@ -2695,6 +2694,7 @@ "require-dev": { "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", + "phpdocumentor/type-resolver": "0.4.*", "phpunit/phpunit": "^6.4" }, "type": "library", @@ -2721,7 +2721,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" + "time": "2019-12-28T18:55:12+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -2772,33 +2772,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.9.0", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" + "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/cbe1df668b3fe136bcc909126a0f529a78d4cbbc", + "reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { @@ -2831,7 +2831,7 @@ "spy", "stub" ], - "time": "2019-10-03T11:07:50+00:00" + "time": "2019-12-22T21:05:45+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3910,16 +3910,16 @@ }, { "name": "seld/phar-utils", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/Seldaek/phar-utils.git", - "reference": "7009b5139491975ef6486545a39f3e6dad5ac30a" + "reference": "84715761c35808076b00908a20317a3a8a67d17e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/7009b5139491975ef6486545a39f3e6dad5ac30a", - "reference": "7009b5139491975ef6486545a39f3e6dad5ac30a", + "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/84715761c35808076b00908a20317a3a8a67d17e", + "reference": "84715761c35808076b00908a20317a3a8a67d17e", "shasum": "" }, "require": { @@ -3950,7 +3950,7 @@ "keywords": [ "phra" ], - "time": "2015-10-13T18:44:15+00:00" + "time": "2020-01-13T10:41:09+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -4005,7 +4005,7 @@ }, { "name": "symfony/finder", - "version": "v4.4.1", + "version": "v4.4.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -4054,16 +4054,16 @@ }, { "name": "symfony/process", - "version": "v4.4.1", + "version": "v4.4.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "51c0135ef3f44c5803b33dc60e96bf4f77752726" + "reference": "b84501ad50adb72a94fb460a5b5c91f693e99c9b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/51c0135ef3f44c5803b33dc60e96bf4f77752726", - "reference": "51c0135ef3f44c5803b33dc60e96bf4f77752726", + "url": "https://api.github.com/repos/symfony/process/zipball/b84501ad50adb72a94fb460a5b5c91f693e99c9b", + "reference": "b84501ad50adb72a94fb460a5b5c91f693e99c9b", "shasum": "" }, "require": { @@ -4099,20 +4099,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2019-11-28T13:33:56+00:00" + "time": "2019-12-06T10:06:46+00:00" }, { "name": "symfony/var-dumper", - "version": "v5.0.1", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "a4862009387721e155be6dc115061f42ee209205" + "reference": "d7bc61d5d335fa9b1b91e14bb16861e8ca50f53a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/a4862009387721e155be6dc115061f42ee209205", - "reference": "a4862009387721e155be6dc115061f42ee209205", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/d7bc61d5d335fa9b1b91e14bb16861e8ca50f53a", + "reference": "d7bc61d5d335fa9b1b91e14bb16861e8ca50f53a", "shasum": "" }, "require": { @@ -4174,7 +4174,7 @@ "debug", "dump" ], - "time": "2019-11-28T14:20:16+00:00" + "time": "2019-12-18T13:50:31+00:00" }, { "name": "theseer/tokenizer", diff --git a/config/ripple_control_group_form.php b/config/ripple_control_group_form.php new file mode 100644 index 000000000..913dac7a7 --- /dev/null +++ b/config/ripple_control_group_form.php @@ -0,0 +1,26 @@ + '{{content}}', + 'input' => '
' + . '' + . '
', + + 'error' => '
' + . '{{content}}' + . '
', + + // Container for error items. + //'errorList' => '', + 'errorList' => '{{content}}', + + // Error item wrapper. + //'errorItem' => '
  • {{text}}
  • ', + 'errorItem' => '
    {{text}}
    ' +]; diff --git a/src/Controller/Component/JsonRequestClientComponent.php b/src/Controller/Component/JsonRequestClientComponent.php index 64e645e0a..e94151511 100644 --- a/src/Controller/Component/JsonRequestClientComponent.php +++ b/src/Controller/Component/JsonRequestClientComponent.php @@ -32,27 +32,12 @@ class JsonRequestClientComponent extends Component return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'base64Message contain invalid base64 characters']; } - $http = new Client(); - - $transactionbody = json_encode([ + return $this->sendRequest(json_encode([ 'session_id' => $session_id, 'transaction_base64' => $base64Message, 'balance' => $user_balance - ]); - $response = $http->post($this->getLoginServerUrl() . '/checkTransaction', $transactionbody, ['type' => 'json']); - $responseStatus = $response->getStatusCode(); - if($responseStatus != 200) { - return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response status code isn\'t 200', 'details' => $responseStatus]; - } - //$responseType = $response->getType(); - //if($responseType != 'application/json') { -// return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t json', 'details' => $responseType]; -// } - $json = $response->getJson(); - if($json == null) { - return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json', 'details' => $responseType]; - } - return ['state' => 'success', 'data' => $json]; + ]), '/checkTransaction'); + } public function getRunningUserTasks($email) @@ -63,22 +48,45 @@ class JsonRequestClientComponent extends Component if(!GenericValidation::email($email, [])) { return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'email is invalid']; } - $http = new Client(); - - $transactionbody = json_encode([ + + return $this->sendRequest(json_encode([ 'email' => $email - ]); - $response = $http->post($this->getLoginServerUrl() . '/getRunningUserTasks', $transactionbody, ['type' => 'json']); - $responseStatus = $response->getStatusCode(); - if($responseStatus != 200) { - return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response status code isn\'t 200', 'details' => $responseStatus]; - } - - $json = $response->getJson(); - if($json == null) { - return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json', 'details' => $responseType]; - } - return ['state' => 'success', 'data' => $json]; + ]), '/getRunningUserTasks'); + } + + public function getUsers($session_id, $searchString) + { + if($searchString == "") { + return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'search string is empty']; + } + if(!is_numeric($session_id)) { + return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'session_id isn\'t numeric']; + } + + return $this->sendRequest(json_encode([ + 'session_id' => $session_id, + 'search' => $searchString + ]), '/getUsers'); + } + + public function sendRequest($transactionBody, $url_last_part) { + $http = new Client(); + + $response = $http->post($this->getLoginServerUrl() . $url_last_part, $transactionBody, ['type' => 'json']); + $responseStatus = $response->getStatusCode(); + if($responseStatus != 200) { + return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response status code isn\'t 200', 'details' => $responseStatus]; + } + //$responseType = $response->getType(); + //if($responseType != 'application/json') { +// return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t json', 'details' => $responseType]; +// } + $json = $response->getJson(); + if($json == null) { + //$responseType = $response->getType(); + return ['state' => 'error', 'type' => 'request error', 'msg' => 'server response isn\'t valid json']; + } + return ['state' => 'success', 'data' => $json]; } static public function getLoginServerUrl() diff --git a/src/Controller/JsonRequestHandlerController.php b/src/Controller/JsonRequestHandlerController.php new file mode 100644 index 000000000..20cfac267 --- /dev/null +++ b/src/Controller/JsonRequestHandlerController.php @@ -0,0 +1,117 @@ +loadComponent('JsonRequestClient'); + //$this->Auth->allow(['add', 'edit']); + $this->Auth->allow('index'); + } + + + public function index() + { + + if($this->request->is('get')) { + $method = $this->request->getQuery('method'); + switch($method) { + case 'getRunningUserTasks': return $this->getRunningUserTasks(); + } + return $this->returnJson(['state' => 'error', 'msg' => 'unknown method for get', 'details' => $method]); + } + else if($this->request->is('post')) { + $jsonData = $this->request->input('json_decode'); + //var_dump($jsonData); + if($jsonData == NULL || !isset($jsonData->method) || !isset($jsonData->transaction)) { + return $this->returnJson(['state' => 'error', 'msg' => 'parameter error']); + } + $method = $jsonData->method; + + switch($method) { + case 'putTransaction': return $this->putTransaction($jsonData->transaction); + case 'userDelete': return $this->userDelete($jsonData->user); + } + return $this->returnJson(['state' => 'error', 'msg' => 'unknown method for post', 'details' => $method]); + } + return $this->returnJson(['state' => 'error', 'msg' => 'no post or get']); + } + + private function putTransaction($transactionBase64) { + $transaction = new Transaction($transactionBase64); + if($transaction->hasErrors()) { + return $this->returnJson(['state' => 'error', 'msg' => 'error parsing transaction', 'details' => $transaction->getErrors()]); + } + if(!$transaction->validate()) { + return $this->returnJsonSaveError($transaction, ['state' => 'error', 'msg' => 'error validate transaction', 'details' => $transaction->getErrors()]); + } + + if ($transaction->save()) { + // success + return $this->returnJson(['state' => 'success']); + } else { + return $this->returnJsonSaveError($transaction, [ + 'state' => 'error', + 'msg' => 'error saving transaction in db', + 'details' => json_encode($transaction->getErrors()) + ]); + } + + return $this->returnJson(['state' => 'success']); + } + + private function userDelete($userPubkeyHex) { + $stateUserTable = TableRegistry::getTableLocator()->get('StateUsers'); + $user = $stateUserTable->find('all')->where(['public_key' => hex2bin($userPubkeyHex)]); + if(!$user || $user->count == 0) { + return $this->returnJson(['state' => 'error', 'msg' => 'user not found']); + } + + } + + private function getRunningUserTasks() { + $session = $this->getRequest()->getSession(); + $state_user_email = $session->read('StateUser.email'); + $requestResult = $this->JsonRequestClient->getRunningUserTasks($state_user_email);; + return $this->returnJson($requestResult); + } + + + private function returnJsonSaveError($transaction, $errorArray) { + $json = json_encode($errorArray); + $stateUserTable = TableRegistry::getTableLocator()->get('StateUsers'); + $pub = $transaction->getFirstPublic(); + $stateUserQuery = $stateUserTable + ->find('all') + ->where(['public_key' => $pub]) + ->contain(false); + if($stateUserQuery->count() == 1) { + $stateErrorsTable = TableRegistry::getTableLocator()->get('StateErrors'); + $stateErrorEntity = $stateErrorsTable->newEntity(); + $stateErrorEntity->state_user_id = $stateUserQuery->first()->id; + $stateErrorEntity->transaction_type_id = $transaction->getTransactionBody()->getTransactionTypeId(); + $stateErrorEntity->message_json = $json; + $stateErrorsTable->save($stateErrorEntity); + } + return $this->returnJsonEncoded($json); + } + + + +} \ No newline at end of file diff --git a/src/Controller/StateUsersController.php b/src/Controller/StateUsersController.php index 87da4e5cb..0ade305cb 100644 --- a/src/Controller/StateUsersController.php +++ b/src/Controller/StateUsersController.php @@ -1,7 +1,11 @@ loadComponent('GradidoNumber'); + $this->loadComponent('JsonRequestClient'); + $this->Auth->allow(['search']); + + } + /** * Index method * @@ -37,6 +51,56 @@ class StateUsersController extends AppController } $this->set('stateUsers', $stateUsers); } + + public function search() + { + $startTime = microtime(true); + $this->viewBuilder()->setLayout('frontend_ripple'); + $session = $this->getRequest()->getSession(); + $result = $this->requestLogin(); + if($result !== true) { + return $result; + } + $user = $session->read('StateUser'); + if($user['role'] != 'admin') { + return $this->redirect(['controller' => 'dashboard', 'action' => 'index']); + } + + $searchForm = new UserSearchForm(); + + $timeUsed = microtime(true) - $startTime; + //$this->set('timeUsed', $timeUsed); + $this->set(compact('timeUsed', 'searchForm')); + + if ($this->request->is('post')) { + $requestData = $this->request->getData(); + + if($searchForm->validate($requestData)) { + //var_dump($requestData); + $searchString = $requestData['search']; + $searchType = 'unknown'; + if(GenericValidation::email($searchString, [])) { + $searchType = 'email'; + } + $resultJson = $this->JsonRequestClient->getUsers($session->read('session_id'), $searchString); + if($resultJson['state'] == 'success') { + $dataJson = $resultJson['data']; + if($dataJson['state'] != 'success') { + if($dataJson['msg'] == 'session not found') { + $session->destroy(); + return $this->redirect(Router::url('/', true) . 'account', 303); + } + } + var_dump($dataJson); + } + + } else { + $this->Flash->error(__('Something was invalid, please try again!')); + } + $timeUsed = microtime(true) - $startTime; + $this->set('timeUsed', $timeUsed); + } + } /** * View method diff --git a/src/Form/UserSearchForm.php b/src/Form/UserSearchForm.php new file mode 100644 index 000000000..e2955e244 --- /dev/null +++ b/src/Form/UserSearchForm.php @@ -0,0 +1,56 @@ +addField('search', ['type' => 'string']); + } + + function validationDefault(Validator $validator) + { + $validator->setProvider('custom', 'App\Model\Validation\GenericValidation'); + /* + $validator->add('receiver_pubkey_hex', 'length', [ + 'rule' => ['length', 64], + 'message' => 'a valid pubkey in hex format is required (64 character)' + ])->add('receiver_pubkey_hex_select', 'length', [ + 'rule' => ['length', 64], + 'message' => 'a valid pubkey in hex format is required (64 character)', + ]); +*/ + // TODO: add validation for used character to prevent hacking attempts + $validator->add('search', 'length', [ + 'rule' => ['maxLength', 50], + 'message' => __('The search text should contain max 50 character') + ]) + //->alphaNumeric('memo', __('Only Alpha Numeric Character allowed')) + ->add('search', 'custom', [ + 'rule' => 'alphaNumeric', + 'provider' => 'custom', + //'message' => __('Only Alpha Numeric Character allowed') + 'message' => __('No HTML Tags like < or > please.') + ]); + return $validator; + } + /* + * $validator->add('title', 'custom', [ + 'rule' => 'customRule', + 'provider' => 'custom', + 'message' => 'The title is not unique enough' +]); + */ + + protected function _execute(array $data) + { + // Send an email. + return true; + } +} \ No newline at end of file diff --git a/src/Template/StateUsers/search.ctp b/src/Template/StateUsers/search.ctp new file mode 100644 index 000000000..bd2bb33a7 --- /dev/null +++ b/src/Template/StateUsers/search.ctp @@ -0,0 +1,32 @@ +assign('title', __('Benutzer suchen')); +// In a View class +$this->loadHelper('Form', [ + 'templates' => 'ripple_control_group_form', +]);//*/ +?> +
    +
    +
    +

    Benutzer suchen

    +
    +
    +
    +
    + Form->create($searchForm, ['class' => 't-header-search-box']) ?> + Form->control('search', ['label' => false, 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Vorname oder Nachname oder E-Mail')]) ?> + Form->button(' ' . __('Datenbank durchsuchen'), ['class' => 'btn btn-sm btn-primary']) ?> +
    +
    +
    +
    +
    +
    +