From 72a08d8c8074fa28574a04940cc2746589ff963a Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Thu, 10 Dec 2020 07:47:46 +0000 Subject: [PATCH] add app requests controller --- config/routes.php | 6 +-- src/Controller/AppRequestsController.php | 61 ++++++++++++++++++++++++ src/Model/Transactions/Record.php | 1 + 3 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/Controller/AppRequestsController.php diff --git a/config/routes.php b/config/routes.php index 6b8097b8a..3400992ac 100644 --- a/config/routes.php +++ b/config/routes.php @@ -57,12 +57,12 @@ Router::scope('/', function (RouteBuilder $routes) { $csrf->whitelistCallback(function ($request) { // Skip token check for API URLs. //die($request->getParam('controller')); - $whitelist = ['JsonRequestHandler', 'ElopageWebhook']; + $whitelist = ['JsonRequestHandler', 'ElopageWebhook', 'AppRequests']; $ajaxWhitelist = ['TransactionSendCoins', 'TransactionCreations']; - + foreach($whitelist as $entry) { if($request->getParam('controller') === $entry) { - if($entry == 'ElopageWebhook') { + if($entry == 'ElopageWebhook' || $entry == 'AppRequests') { return true; } if($request->clientIp() == '127.0.0.1' || $request->clientIp() == 'localhost') { diff --git a/src/Controller/AppRequestsController.php b/src/Controller/AppRequestsController.php new file mode 100644 index 000000000..c36ddf161 --- /dev/null +++ b/src/Controller/AppRequestsController.php @@ -0,0 +1,61 @@ +loadComponent('JsonRequestClient'); + $this->loadComponent('JsonRpcRequestClient'); + //$this->Auth->allow(['add', 'edit']); + $this->Auth->allow('index'); + } + + + public function index() + { + if($this->request->is('get')) { + $method = $this->request->getQuery('method'); + switch($method) { + + } + 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)) { + return $this->returnJson(['state' => 'error', 'msg' => 'parameter error']); + } + $method = $jsonData->method; + + switch($method) { + + } + return $this->returnJson(['state' => 'error', 'msg' => 'unknown method for post', 'details' => $method]); + } + return $this->returnJson(['state' => 'error', 'msg' => 'no post or get']); + } + + private function acquireAccessToken($session_id) + { + + } + +} + \ No newline at end of file diff --git a/src/Model/Transactions/Record.php b/src/Model/Transactions/Record.php index faec7c479..2a6f56483 100644 --- a/src/Model/Transactions/Record.php +++ b/src/Model/Transactions/Record.php @@ -365,6 +365,7 @@ class Record case 'BLANK': return false; } + return false; } /*!