diff --git a/config/routes.php b/config/routes.php
index 1290ad06e..0aec385cc 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -55,7 +55,7 @@ Router::scope('/', function (RouteBuilder $routes) {
$csrf->whitelistCallback(function ($request) {
// Skip token check for API URLs.
//die($request->getParam('controller'));
- if($request->getParam('controller') === 'TransactionJsonRequestHandler') {
+ if($request->getParam('controller') === 'JsonRequestHandler') {
return true;
}
});
diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php
index 66a1b6cd5..660be10ae 100644
--- a/src/Controller/AppController.php
+++ b/src/Controller/AppController.php
@@ -146,9 +146,11 @@ class AppController extends Controller
if($session_id != 0) {
$userStored = $session->read('StateUser');
$transactionPendings = $session->read('Transactions.pending');
+ $transactionExecutings = $session->read('Transaction.executing');
if($session->read('session_id') != $session_id ||
( $userStored && !isset($userStored['id'])) ||
- intval($transactionPendings) > 0) {
+ intval($transactionPendings) > 0 ||
+ intval($transactionExecutings) > 0) {
$http = new Client();
try {
$loginServer = Configure::read('LoginServer');
@@ -170,8 +172,10 @@ class AppController extends Controller
}
//var_dump($json);
$transactionPendings = $json['Transaction.pending'];
+ $transactionExecuting = $json['Transaction.executing'];
//echo "read transaction pending: $transactionPendings
";
$session->write('Transactions.pending', $transactionPendings);
+ $session->write('Transaction.executing', $transactionExecuting);
$session->write('session_id', $session_id);
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
if($json['user']['public_hex'] != '') {
diff --git a/src/Controller/Component/JsonRequestClientComponent.php b/src/Controller/Component/JsonRequestClientComponent.php
index bf112bd4e..64e645e0a 100644
--- a/src/Controller/Component/JsonRequestClientComponent.php
+++ b/src/Controller/Component/JsonRequestClientComponent.php
@@ -7,6 +7,8 @@
*/
namespace App\Controller\Component;
+use App\Model\Validation\GenericValidation;
+
use Cake\Controller\Component;
use Cake\Http\Client;
use Cake\Core\Configure;
@@ -53,6 +55,32 @@ class JsonRequestClientComponent extends Component
return ['state' => 'success', 'data' => $json];
}
+ public function getRunningUserTasks($email)
+ {
+ if($email == "") {
+ return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'email is empty'];
+ }
+ if(!GenericValidation::email($email, [])) {
+ return ['state' => 'error', 'type' => 'parameter error', 'msg' => 'email is invalid'];
+ }
+ $http = new Client();
+
+ $transactionbody = 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];
+ }
+
static public function getLoginServerUrl()
{
$loginServer = Configure::read('LoginServer');
diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php
index 8e5b44152..cf242b5a0 100644
--- a/src/Controller/DashboardController.php
+++ b/src/Controller/DashboardController.php
@@ -40,7 +40,15 @@ class DashboardController extends AppController
}
$user = $session->read('StateUser');
+ $serverUser = $this->Auth->user('id');
+ if($serverUser) {
+ $adminErrorsTable = TableRegistry::getTableLocator()->get('AdminErrors');
+ $adminErrorCount = $adminErrorsTable->find('all')->count();
+ $this->set('adminErrorCount', $adminErrorCount);
+ }
+
$this->set('user', $user);
+ $this->set('serverUser', $serverUser);
$this->set('timeUsed', microtime(true) - $startTime);
}
diff --git a/src/Controller/StateBalancesController.php b/src/Controller/StateBalancesController.php
index 0f81cf4c5..d823c9257 100644
--- a/src/Controller/StateBalancesController.php
+++ b/src/Controller/StateBalancesController.php
@@ -132,6 +132,7 @@ class StateBalancesController extends AppController
}
uasort($transactions, array($this, 'sortTransactions'));
$this->set('transactions', $transactions);
+ $this->set('transactionExecutingCount', $session->read('Transaction.executing'));
$this->set('balance', $session->read('StateUser.balance'));
$this->set('timeUsed', microtime(true) - $startTime);
}
diff --git a/src/Controller/TransactionCreationsController.php b/src/Controller/TransactionCreationsController.php
index c9665d707..25b751a10 100644
--- a/src/Controller/TransactionCreationsController.php
+++ b/src/Controller/TransactionCreationsController.php
@@ -244,6 +244,7 @@ class TransactionCreationsController extends AppController
$this->set('activeUser', $user);
$this->set('creationForm', $creationForm);
+ $this->set('transactionExecutingCount', $session->read('Transaction.executing'));
$this->set('timeUsed', microtime(true) - $startTime);
if ($this->request->is('post')) {
diff --git a/src/Controller/TransactionJsonRequestHandlerController.php b/src/Controller/TransactionJsonRequestHandlerController.php
deleted file mode 100644
index 651ccc97a..000000000
--- a/src/Controller/TransactionJsonRequestHandlerController.php
+++ /dev/null
@@ -1,97 +0,0 @@
-Auth->allow(['add', 'edit']);
- $this->Auth->allow('index');
- }
-
-
- public function index()
- {
- 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', 'details' => $method]);
- }
- return $this->returnJson(['state' => 'error', 'msg' => 'no post']);
- }
-
- 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 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/Template/Dashboard/index.ctp b/src/Template/Dashboard/index.ctp
index d975d69a4..4aa08a475 100644
--- a/src/Template/Dashboard/index.ctp
+++ b/src/Template/Dashboard/index.ctp
@@ -15,6 +15,7 @@ $this->assign('title', __('Willkommen') . ' ' . $user['first_name'] . '&nbs
= round($requestTime * 1000.0) ?> ms