mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add app requests controller
This commit is contained in:
parent
60449797e8
commit
72a08d8c80
@ -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') {
|
||||
|
||||
61
src/Controller/AppRequestsController.php
Normal file
61
src/Controller/AppRequestsController.php
Normal 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -365,6 +365,7 @@ class Record
|
||||
case 'BLANK':
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user