mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
check also session from post request
This commit is contained in:
parent
d2f63baa00
commit
af1696c358
@ -52,8 +52,10 @@ class AppRequestsController extends AppController
|
|||||||
return $this->returnJson(['state' => 'error', 'msg' => 'no post or get']);
|
return $this->returnJson(['state' => 'error', 'msg' => 'no post or get']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkAndCopyRequiredFields($fields, &$param) {
|
private function checkAndCopyRequiredFields($fields, &$param, $data = null) {
|
||||||
$data = $this->request->input('json_decode');
|
if($data == null) {
|
||||||
|
$data = $this->request->input('json_decode');
|
||||||
|
}
|
||||||
foreach($fields as $field) {
|
foreach($fields as $field) {
|
||||||
if(is_array($field)) {
|
if(is_array($field)) {
|
||||||
$one_exist = false;
|
$one_exist = false;
|
||||||
@ -89,9 +91,16 @@ class AppRequestsController extends AppController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseParameterForCreateTransaction(&$param)
|
private function parseParameterForCreateTransaction(&$param, $data = null)
|
||||||
{
|
{
|
||||||
$login_request_result = $this->requestLogin(0, false);
|
if($data == null) {
|
||||||
|
$data = $this->request->input('json_decode');
|
||||||
|
}
|
||||||
|
$session_id = 0;
|
||||||
|
if(isset($data['session_id'])) {
|
||||||
|
$session_id = $data['session_id'];
|
||||||
|
}
|
||||||
|
$login_request_result = $this->requestLogin($session_id, false);
|
||||||
if($login_request_result !== true) {
|
if($login_request_result !== true) {
|
||||||
return $login_request_result;
|
return $login_request_result;
|
||||||
}
|
}
|
||||||
@ -100,7 +109,7 @@ class AppRequestsController extends AppController
|
|||||||
$param['blockchain_type'] = $this->blockchainType;
|
$param['blockchain_type'] = $this->blockchainType;
|
||||||
|
|
||||||
$this->rewriteKeys($data, ['email' => 'target_email', 'username' => 'target_username', 'pubkey' => 'target_pubkey']);
|
$this->rewriteKeys($data, ['email' => 'target_email', 'username' => 'target_username', 'pubkey' => 'target_pubkey']);
|
||||||
$required_fields = $this->checkAndCopyRequiredFields(['amount', ['target_email', 'target_username', 'target_pubkey']], $param);
|
$required_fields = $this->checkAndCopyRequiredFields(['amount', ['target_email', 'target_username', 'target_pubkey']], $param, $data);
|
||||||
if($required_fields !== true) {
|
if($required_fields !== true) {
|
||||||
return $required_fields;
|
return $required_fields;
|
||||||
}
|
}
|
||||||
@ -134,13 +143,13 @@ class AppRequestsController extends AppController
|
|||||||
if(!$this->request->is('post')) {
|
if(!$this->request->is('post')) {
|
||||||
return $this->returnJson(['state' => 'error', 'msg' => 'no post']);
|
return $this->returnJson(['state' => 'error', 'msg' => 'no post']);
|
||||||
}
|
}
|
||||||
|
$data = $this->request->input('json_decode');
|
||||||
$params = [];
|
$params = [];
|
||||||
$result = $this->parseParameterForCreateTransaction($params);
|
$result = $this->parseParameterForCreateTransaction($params, $data);
|
||||||
if($result !== true) {
|
if($result !== true) {
|
||||||
return $this->returnJson($result);
|
return $this->returnJson($result);
|
||||||
}
|
}
|
||||||
$required_fields = $this->checkAndCopyRequiredFields(['target_date'], $params);
|
$required_fields = $this->checkAndCopyRequiredFields(['target_date'], $params, $data);
|
||||||
if($required_fields !== true) {
|
if($required_fields !== true) {
|
||||||
return $this->returnJson($required_fields);
|
return $this->returnJson($required_fields);
|
||||||
}
|
}
|
||||||
@ -202,13 +211,13 @@ class AppRequestsController extends AppController
|
|||||||
if(!$this->request->is('post')) {
|
if(!$this->request->is('post')) {
|
||||||
return $this->returnJson(['state' => 'error', 'msg' => 'no post']);
|
return $this->returnJson(['state' => 'error', 'msg' => 'no post']);
|
||||||
}
|
}
|
||||||
|
$data = $this->request->input('json_decode');
|
||||||
$params = [];
|
$params = [];
|
||||||
$result = $this->parseParameterForCreateTransaction($params);
|
$result = $this->parseParameterForCreateTransaction($params, $data);
|
||||||
if($result !== true) {
|
if($result !== true) {
|
||||||
return $this->returnJson($result);
|
return $this->returnJson($result);
|
||||||
}
|
}
|
||||||
$required_fields = $this->checkAndCopyRequiredFields(['target_date'], $params);
|
$required_fields = $this->checkAndCopyRequiredFields(['target_date'], $params, $data);
|
||||||
if($required_fields !== true) {
|
if($required_fields !== true) {
|
||||||
return $this->returnJson($required_fields);
|
return $this->returnJson($required_fields);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user