add app requests controller

This commit is contained in:
Dario Rekowski on RockPI 2020-12-10 07:47:46 +00:00 committed by Ulf Gebhardt
parent 60449797e8
commit 72a08d8c80
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
3 changed files with 65 additions and 3 deletions

View File

@ -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') {

View File

@ -0,0 +1,61 @@
<?php
/*!
* @author: Dario Rekowski
* @date : 2020-12-01
* @brief: Controller for all ajax-json requests caming from mobile app
*
* Everything is allowed to call them, so caution!
*/
namespace App\Controller;
use App\Controller\AppController;
use Cake\ORM\TableRegistry;
use Cake\Http\Client;
use Cake\Core\Configure;
class AppRequestsController extends AppController
{
public function initialize()
{
parent::initialize();
$this->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)
{
}
}

View File

@ -365,6 +365,7 @@ class Record
case 'BLANK':
return false;
}
return false;
}
/*!