From 14324649c837a0a132a716a780864873da86cca0 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Thu, 6 May 2021 14:52:59 +0000 Subject: [PATCH 01/32] update auto-generated transactions/add function to produce a transaction with valid txhash --- .../src/Controller/TransactionsController.php | 13 +++-- .../src/Model/Table/TransactionsTable.php | 54 +++++++++++++++++++ .../src/Template/Transactions/add.ctp | 3 +- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/community_server/src/Controller/TransactionsController.php b/community_server/src/Controller/TransactionsController.php index 4f8e04c2b..90e78b7fb 100644 --- a/community_server/src/Controller/TransactionsController.php +++ b/community_server/src/Controller/TransactionsController.php @@ -313,15 +313,20 @@ class TransactionsController extends AppController if ($this->request->is('post')) { $transaction = $this->Transactions->patchEntity($transaction, $this->request->getData()); if ($this->Transactions->save($transaction)) { - $this->Flash->success(__('The transaction has been saved.')); - - return $this->redirect(['action' => 'index']); + $result = $this->Transactions->updateTxHash($transaction, 'start decay'); + if($result === true) { + $this->Flash->success(__('The transaction has been saved.')); + return $this->redirect(['action' => 'index']); + } else { + $this->Flash->error(__('Error by saving: ' . json_encode($result))); + } } $this->Flash->error(__('The transaction could not be saved. Please, try again.')); } $stateGroups = $this->Transactions->StateGroups->find('list', ['limit' => 200]); $transactionTypes = $this->Transactions->TransactionTypes->find('list', ['limit' => 200]); - $this->set(compact('transaction', 'stateGroups', 'transactionTypes')); + $blockchainTypes = $this->Transactions->BlockchainTypes->find('list'); + $this->set(compact('transaction', 'stateGroups', 'transactionTypes', 'blockchainTypes')); } /** diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 893482e3f..fdd437076 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -266,4 +266,58 @@ class TransactionsTable extends Table return $final_transactions; } + + public function updateTxHash($transaction, $signatureMapString) + { + $transaction_id = $transaction->id; + $previousTxHash = null; + if($transaction_id > 1) { + try { + $previousTransaction = $this + ->find('all', ['contain' => false]) + ->select(['tx_hash']) + ->where(['id' => $transaction_id - 1]) + ->first(); + /*$previousTransaction = $transactionsTable->get($this->mTransactionID - 1, [ + 'contain' => false, + 'fields' => ['tx_hash'] + ]);*/ + } catch(Cake\Datasource\Exception\RecordNotFoundException $ex) { + return ['state' => 'error', 'msg' => 'previous transaction not found', 'details' => $ex->getMessage()]; + } + if(!$previousTransaction) { + // shouldn't occur + return ['state' => 'error', 'msg' => 'previous transaction not found']; + } + $previousTxHash = $previousTransaction->tx_hash; + } + try { + //$transactionEntity->received = $transactionsTable->get($transactionEntity->id, ['contain' => false, 'fields' => ['received']])->received; + $transaction->received = $this + ->find('all', ['contain' => false]) + ->where(['id' => $transaction->id]) + ->select(['received'])->first()->received; + } catch(Cake\Datasource\Exception\RecordNotFoundException $ex) { + return ['state' => 'error', 'msg' => 'current transaction not found in db', 'details' => $ex->getMessage()]; + } + + // calculate tx hash + // previous tx hash + id + received + sigMap as string + // Sodium use for the generichash function BLAKE2b today (11.11.2019), mabye change in the future + $state = \Sodium\crypto_generichash_init(); + //echo "prev hash: $previousTxHash\n"; + if($previousTxHash != null) { + \Sodium\crypto_generichash_update($state, stream_get_contents($previousTxHash)); + } + //echo "id: " . $transactionEntity->id . "\n"; + \Sodium\crypto_generichash_update($state, strval($transaction->id)); + //echo "received: " . $transactionEntity->received; + \Sodium\crypto_generichash_update($state, $transaction->received->i18nFormat('yyyy-MM-dd HH:mm:ss')); + \Sodium\crypto_generichash_update($state, $signatureMapString); + $transaction->tx_hash = \Sodium\crypto_generichash_final($state); + if ($this->save($transaction)) { + return true; + } + return ['state' => 'error', 'msg' => 'error by saving transaction', 'details' => $transaction->getErrors()]; + } } diff --git a/community_server/src/Template/Transactions/add.ctp b/community_server/src/Template/Transactions/add.ctp index 59782d944..012d82027 100644 --- a/community_server/src/Template/Transactions/add.ctp +++ b/community_server/src/Template/Transactions/add.ctp @@ -35,7 +35,8 @@ Form->control('state_group_id', ['options' => $stateGroups]); echo $this->Form->control('transaction_type_id', ['options' => $transactionTypes]); - echo $this->Form->control('received'); + echo $this->Form->control('memo', ['type' => 'textarea']); + echo $this->Form->control('blockchain_type_id', ['options' => $blockchainTypes]); ?> Form->button(__('Submit')) ?> From 4a982fc5753481beec22a5e34eeb87cd80b5f0d4 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Thu, 6 May 2021 14:55:03 +0000 Subject: [PATCH 02/32] add new transaction type to setup script, by existing db please add the line by yourself! --- .../db/setup_db_tables/insert_transaction_types.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/community_server/db/setup_db_tables/insert_transaction_types.sql b/community_server/db/setup_db_tables/insert_transaction_types.sql index 02ef8374a..37919045d 100644 --- a/community_server/db/setup_db_tables/insert_transaction_types.sql +++ b/community_server/db/setup_db_tables/insert_transaction_types.sql @@ -6,5 +6,5 @@ INSERT INTO `transaction_types` (`id`, `name`, `text`) VALUES (5, 'group remove member', 'remove user from group, maybe he was moved elsewhere'), (6, 'hedera topic create', 'create new topic on hedera'), (7, 'hedera topic send message', 'send consensus message over hedera topic'), -(8, 'hedera account create', 'create new account on hedera for holding some founds with unencrypted keys'); - +(8, 'hedera account create', 'create new account on hedera for holding some founds with unencrypted keys'), +(9, 'decay start', 'signalize the starting point for decay calculation, allowed only once per chain'); From b0b237122b5409e68f686d468a60672e18f04127 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 7 May 2021 10:01:40 +0200 Subject: [PATCH 03/32] 233-Support-Button fix, and col error fix --- frontend/src/views/Layout/ContentFooter.vue | 11 +++++++++++ .../src/views/Pages/AccountOverview/GddStatus.vue | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index b261cafb3..b531364e3 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -39,6 +39,17 @@ > {{ $t('whitepaper') }} + + {{ $t('site.navbar.support') }} + diff --git a/frontend/src/views/Pages/AccountOverview/GddStatus.vue b/frontend/src/views/Pages/AccountOverview/GddStatus.vue index 96267e335..8698d1fdc 100644 --- a/frontend/src/views/Pages/AccountOverview/GddStatus.vue +++ b/frontend/src/views/Pages/AccountOverview/GddStatus.vue @@ -1,7 +1,7 @@ From d9d78d1539c638696ff1bffaf84e6112d6fed05f Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Mon, 10 May 2021 15:21:02 +0000 Subject: [PATCH 18/32] fill migration controller, update some other functions to using same result format --- .../src/Controller/AppController.php | 16 +++ .../src/Controller/MigrationsController.php | 47 ++++++++ .../Controller/StateBalancesController.php | 2 +- community_server/src/Model/Table/AppTable.php | 23 ++++ .../src/Model/Table/StateBalancesTable.php | 39 +++---- .../Table/StateUserTransactionsTable.php | 2 +- .../src/Model/Table/TransactionsTable.php | 104 ++++++++++++++++++ .../src/Template/Migrations/migrate.ctp | 18 +++ 8 files changed, 230 insertions(+), 21 deletions(-) create mode 100644 community_server/src/Model/Table/AppTable.php create mode 100644 community_server/src/Template/Migrations/migrate.ctp diff --git a/community_server/src/Controller/AppController.php b/community_server/src/Controller/AppController.php index 1cdcf4418..80690b238 100644 --- a/community_server/src/Controller/AppController.php +++ b/community_server/src/Controller/AppController.php @@ -156,8 +156,24 @@ class AppController extends Controller } } + protected function checkForMigration($html = true) + { + $migrationsTable = TableRegistry::getTableLocator()->get('Migrations'); + $last_migration = $migrationsTable->find()->last(); + $current_db_version = 1; + if($last_migration) { + $current_db_version = $last_migration->db_version; + } + $php_data_version = 2; + if($current_db_version < $php_data_version) { + $this->redirect(['controller' => 'Migrations', 'action' => 'migrate', $html, $current_db_version]); + } + } + + protected function requestLogin($sessionId = 0, $redirect = true) { + $this->checkForMigration($redirect); $session = $this->getRequest()->getSession(); // check login // disable encryption for cookies diff --git a/community_server/src/Controller/MigrationsController.php b/community_server/src/Controller/MigrationsController.php index 93a1b8044..c2febef0f 100644 --- a/community_server/src/Controller/MigrationsController.php +++ b/community_server/src/Controller/MigrationsController.php @@ -2,6 +2,7 @@ namespace App\Controller; use App\Controller\AppController; +use Cake\ORM\TableRegistry; /** * Migrations Controller @@ -23,6 +24,52 @@ class MigrationsController extends AppController $this->set(compact('migrations')); } + + protected function callFunctions(array $callables) + { + foreach($callables as $callable) { + $result = call_user_func($callable); + if(!$result['success']) { + return $result; + } + } + return ['success' => true]; + } + + public function migrate($html, $current_db_version) + { + $startTime = microtime(true); + $stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions'); + $transactionsTable = TableRegistry::getTableLocator()->get('Transactions'); + $stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances'); + + $new_db_version = 1; + + $commands = []; + // migrate from version 1 to 2 + if($current_db_version == 1) { + $stateUserTransactionsTable->truncate(); + $commands = [ + [$transactionsTable, 'fillStateUserTransactions'], + [$stateBalancesTable, 'updateAllBalances'] + ]; + $new_db_version = 2; + } + + $migration_result = $this->callFunctions($commands); + if($migration_result['success']) { + $migration_entity = $this->Migrations->newEntity(); + $migration_entity->db_version = $new_db_version; + $this->Migrations->save($migration_entity); + } + if(!$html) { + return $this->returnJson($migration_result); + } else { + $this->set('db_version', $current_db_version); + $this->set('result', $migration_result); + $this->set('timeUsed', microtime(true) - $startTime); + } + } /** * View method diff --git a/community_server/src/Controller/StateBalancesController.php b/community_server/src/Controller/StateBalancesController.php index 3994b989a..655dbc026 100644 --- a/community_server/src/Controller/StateBalancesController.php +++ b/community_server/src/Controller/StateBalancesController.php @@ -62,7 +62,7 @@ class StateBalancesController extends AppController $user = $session->read('StateUser'); $update_balance_result = $this->StateBalances->updateBalances($user['id']); - if($update_balance_result !== true) { + if($update_balance_result['success'] !== true) { $this->addAdminError('StateBalances', 'overview', $update_balance_result, $user['id']); } // sendRequestGDT diff --git a/community_server/src/Model/Table/AppTable.php b/community_server/src/Model/Table/AppTable.php new file mode 100644 index 000000000..3a281afcc --- /dev/null +++ b/community_server/src/Model/Table/AppTable.php @@ -0,0 +1,23 @@ +schema()->truncateSql($this->connection()); + foreach ($truncateCommands as $truncateCommand) { + $this->connection()->query($truncateCommand); + } + } +} diff --git a/community_server/src/Model/Table/StateBalancesTable.php b/community_server/src/Model/Table/StateBalancesTable.php index 4e91c2948..87e961c5d 100644 --- a/community_server/src/Model/Table/StateBalancesTable.php +++ b/community_server/src/Model/Table/StateBalancesTable.php @@ -113,6 +113,20 @@ class StateBalancesTable extends Table } + public function updateAllBalances() + { + $stateUserTable = TableRegistry::getTableLocator()->get('StateUsers'); + $state_users = $stateUserTable->find()->select(['id'])->contain([]); + foreach($state_users as $state_user) { + $result = $this->updateBalances($state_user->id); + if($result['success'] === false) { + $result['state_user_id'] = $state_user->id; + return $result; + } + } + return ['success' => true]; + } + public function updateBalances($stateUserId) { $stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions'); @@ -128,7 +142,7 @@ class StateBalancesTable extends Table ; if(!$state_user_transactions || !$state_user_transactions->count()) { - return true; + return ['success' => true]; } // first: decide what todo @@ -222,40 +236,27 @@ class StateBalancesTable extends Table $transaction = $transactions_indiced[$state_user_transaction->transaction_id]; if($transaction->transaction_type_id > 2) { continue; - } - //echo "transaction id: ".$transaction->id . "
"; - $amount_date = null; + } $amount = 0; if($transaction->transaction_type_id == 1) { // creation - $temp = $transaction->transaction_creation; - - /*$balance_temp = $this->newEntity(); - $balance_temp->amount = $temp->amount; - $balance_temp->record_date = $temp->target_date; - */ - $amount = intval($temp->amount);//$balance_temp->partDecay($transaction->received); - $amount_date = $temp->target_date; - - //$amount_date = + $amount = intval($transaction->transaction_creation->amount); } else if($transaction->transaction_type_id == 2) { // transfer - $temp = $transaction->transaction_send_coin; $amount = intval($temp->amount); // reverse if sender if($stateUserId == $temp->state_user_id) { $amount *= -1.0; } - $amount_date = $transaction->received; - } + $amount_date = $transaction->received; if($i == 0) { $balance_cursor->amount = $amount; } else { //$balance_cursor->amount = $balance_cursor->partDecay($amount_date) + $amount; $balance_cursor->amount = - $this->calculateDecay($balance_cursor->amount, $balance_cursor->recordDate, $amount_date) + $this->calculateDecay($balance_cursor->amount, $balance_cursor->record_date, $amount_date) + $amount; } //echo "new balance: " . $balance_cursor->amount . "
"; @@ -294,7 +295,7 @@ class StateBalancesTable extends Table return ['success' => false, 'error' => 'error saving state balance', 'details' => $state_balance->getErrors()]; } } - return true; + return ['success' => true]; } diff --git a/community_server/src/Model/Table/StateUserTransactionsTable.php b/community_server/src/Model/Table/StateUserTransactionsTable.php index 6cfe94a23..2c984d964 100644 --- a/community_server/src/Model/Table/StateUserTransactionsTable.php +++ b/community_server/src/Model/Table/StateUserTransactionsTable.php @@ -22,7 +22,7 @@ use Cake\Validation\Validator; * @method \App\Model\Entity\StateUserTransaction[] patchEntities($entities, array $data, array $options = []) * @method \App\Model\Entity\StateUserTransaction findOrCreate($search, callable $callback = null, $options = []) */ -class StateUserTransactionsTable extends Table +class StateUserTransactionsTable extends AppTable { /** * Initialize method diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 71d301722..9ae2fe02a 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -335,4 +335,108 @@ class TransactionsTable extends Table } return $transaction->first()->received; } + + public function fillStateUserTransactions() + { + $missing_transaction_ids = []; + $transaction_ids = $this + ->find('all') + ->select(['id', 'transaction_type_id']) + ->order(['id']) + ->all() + ; + $state_user_transaction_ids = $this->StateUserTransactions + ->find('all') + ->select(['transaction_id']) + ->group(['transaction_id']) + ->order(['transaction_id']) + ->toArray() + ; + $i2 = 0; + $count = count($state_user_transaction_ids); + foreach($transaction_ids as $tr_id) { + //echo "$i1: "; + if($i2 >= $count) { + $missing_transaction_ids[] = $tr_id; + //echo "adding to missing: $tr_id, continue
"; + continue; + } + $stu_id = $state_user_transaction_ids[$i2]; + if($tr_id->id == $stu_id->transaction_id) { + $i2++; + //echo "after i2++: $i2
"; + } else if($tr_id->id < $stu_id->transaction_id) { + $missing_transaction_ids[] = $tr_id; + //echo "adding to missing: $tr_id
"; + } + } + + + $tablesForType = [ + 1 => $this->TransactionCreations, + 2 => $this->TransactionSendCoins, + 3 => $this->TransactionGroupCreates, + 4 => $this->TransactionGroupAddaddress, + 5 => $this->TransactionGroupAddaddress + ]; + $idsForType = []; + foreach($missing_transaction_ids as $i => $transaction) { + if(!isset($idsForType[$transaction->transaction_type_id])) { + $idsForType[$transaction->transaction_type_id] = []; + } + $idsForType[$transaction->transaction_type_id][] = $transaction->id; + } + $entities = []; + $state_user_ids = []; + foreach($idsForType as $type_id => $transaction_ids) { + $specific_transactions = $tablesForType[$type_id]->find('all')->where(['transaction_id IN' => $transaction_ids])->toArray(); + $keys = $tablesForType[$type_id]->getSchema()->columns(); + //var_dump($keys); + foreach($specific_transactions as $specific) { + + foreach($keys as $key) { + if(preg_match('/_user_id/', $key)) { + $entity = $this->StateUserTransactions->newEntity(); + $entity->transaction_id = $specific['transaction_id']; + $entity->transaction_type_id = $type_id; + $entity->state_user_id = $specific[$key]; + if(!in_array($entity->state_user_id, $state_user_ids)) { + array_push($state_user_ids, $entity->state_user_id); + } + $entities[] = $entity; + } + } + } + } + //var_dump($entities); + $stateUsersTable = TableRegistry::getTableLocator()->get('StateUsers'); + $existingStateUsers = $stateUsersTable->find('all')->select(['id'])->where(['id IN' => $state_user_ids])->order(['id'])->all(); + $existing_state_user_ids = []; + $finalEntities = []; + foreach($existingStateUsers as $stateUser) { + $existing_state_user_ids[] = $stateUser->id; + } + foreach($entities as $entity) { + if(in_array($entity->state_user_id, $existing_state_user_ids)) { + array_push($finalEntities, $entity); + } + } + + $results = $this->StateUserTransactions->saveMany($finalEntities); + $errors = []; + foreach($results as $i => $res) { + if($res == false) { + $errors[] = $finalEntities[$i]->getErrors(); + } + } + if(count($errors) == 0) { + $result = ['success' => true]; + } else { + $result = ['success' => false, 'msg' => 'error by saving at least one state user transaction', 'errors' => $errors]; + } + + + + return $result; + } } diff --git a/community_server/src/Template/Migrations/migrate.ctp b/community_server/src/Template/Migrations/migrate.ctp new file mode 100644 index 000000000..6ceeec81c --- /dev/null +++ b/community_server/src/Template/Migrations/migrate.ctp @@ -0,0 +1,18 @@ +

Migrate DB

+

Migrate from Version

+ +

Success

+ +

Error

+

+ +

Html->link('Back to Dashboard', ['controller' => 'Dashboard', 'action' => 'index']) ?>

+); From a22593925a15d00db3afbccb5cc7228f295fabd2 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Mon, 10 May 2021 15:37:39 +0000 Subject: [PATCH 19/32] more migrations --- .../db/setup_db_tables/insert_migrations.sql | 2 + .../src/Controller/MigrationsController.php | 6 +- .../src/Model/Table/BlockchainTypesTable.php | 35 ++++++++++- .../src/Model/Table/TransactionTypesTable.php | 60 ++++++++++++++++++- 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 community_server/db/setup_db_tables/insert_migrations.sql diff --git a/community_server/db/setup_db_tables/insert_migrations.sql b/community_server/db/setup_db_tables/insert_migrations.sql new file mode 100644 index 000000000..e6f38117d --- /dev/null +++ b/community_server/db/setup_db_tables/insert_migrations.sql @@ -0,0 +1,2 @@ +INSERT INTO `migrations` (`id`, `db_version`) VALUES +(1, 2); diff --git a/community_server/src/Controller/MigrationsController.php b/community_server/src/Controller/MigrationsController.php index c2febef0f..ddf02bfdc 100644 --- a/community_server/src/Controller/MigrationsController.php +++ b/community_server/src/Controller/MigrationsController.php @@ -41,7 +41,9 @@ class MigrationsController extends AppController $startTime = microtime(true); $stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions'); $transactionsTable = TableRegistry::getTableLocator()->get('Transactions'); + $transactionTypesTable = TableRegistry::getTableLocator()->get('TransactionTypes'); $stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances'); + $blockchainTypesTable = TableRegistry::getTableLocator()->get('BlockchainTypes'); $new_db_version = 1; @@ -51,7 +53,9 @@ class MigrationsController extends AppController $stateUserTransactionsTable->truncate(); $commands = [ [$transactionsTable, 'fillStateUserTransactions'], - [$stateBalancesTable, 'updateAllBalances'] + [$stateBalancesTable, 'updateAllBalances'], + [$blockchainTypesTable, 'fillWithDefault'], + [$transactionTypesTable, 'fillWithDefault'] ]; $new_db_version = 2; } diff --git a/community_server/src/Model/Table/BlockchainTypesTable.php b/community_server/src/Model/Table/BlockchainTypesTable.php index 90213ac9f..252fb8fd7 100644 --- a/community_server/src/Model/Table/BlockchainTypesTable.php +++ b/community_server/src/Model/Table/BlockchainTypesTable.php @@ -18,7 +18,7 @@ use Cake\Validation\Validator; * @method \App\Model\Entity\BlockchainType[] patchEntities($entities, array $data, array $options = []) * @method \App\Model\Entity\BlockchainType findOrCreate($search, callable $callback = null, $options = []) */ -class BlockchainTypesTable extends Table +class BlockchainTypesTable extends AppTable { /** * Initialize method @@ -65,4 +65,37 @@ class BlockchainTypesTable extends Table return $validator; } + + public function fillWithDefault() + { + $entry_contents = [ + [ + 'id' => 1, + 'name' => 'mysql', + 'text' => 'use mysql db as blockchain, work only with single community-server', + 'symbol' => NULL + ], + [ + 'id' => 2, + 'name' => 'hedera', + 'text' => 'use hedera for transactions', + 'symbol' => 'HBAR' + ] + ]; + $entities = $this->newEntities($entry_contents); + $this->truncate(); + $save_results = $this->saveMany($entities); + $errors = []; + foreach($save_results as $i => $result) + { + if(!$result) { + $errors[] = $entities[$i]->getErrors(); + } + } + if(count($errors) > 0) { + return ['success' => false, 'msg' => 'error by saving blockchain types', 'errors' => $errors]; + } + return ['success' => true]; + + } } diff --git a/community_server/src/Model/Table/TransactionTypesTable.php b/community_server/src/Model/Table/TransactionTypesTable.php index 5cc842f5e..7669ff2b3 100644 --- a/community_server/src/Model/Table/TransactionTypesTable.php +++ b/community_server/src/Model/Table/TransactionTypesTable.php @@ -20,7 +20,7 @@ use Cake\Validation\Validator; * @method \App\Model\Entity\TransactionType[] patchEntities($entities, array $data, array $options = []) * @method \App\Model\Entity\TransactionType findOrCreate($search, callable $callback = null, $options = []) */ -class TransactionTypesTable extends Table +class TransactionTypesTable extends AppTable { /** * Initialize method @@ -66,4 +66,62 @@ class TransactionTypesTable extends Table return $validator; } + + public function fillWithDefault() + { + + $entry_contents = [ + [ + 'id' => 1, + 'name' => 'creation', + 'text' => 'create new gradidos for member and also for group (in development)', + ], [ + 'id' => 2, + 'name' => 'transfer', + 'text' => 'send gradidos from one member to another, also cross group transfer', + ], [ + 'id' => 3, + 'name' => 'group create', + 'text' => 'create a new group, trigger creation of new hedera topic and new blockchain on node server' + ], [ + 'id' => 4, + 'name' => 'group add member', + 'text' => 'add user to a group or move if he was already in a group' + ], [ + 'id' => 5, + 'name' => 'group remove member', + 'text' => 'remove user from group, maybe he was moved elsewhere' + ],[ + 'id' => 6, + 'name' => 'hedera topic create', + 'text' => 'create new topic on hedera' + ],[ + 'id' => 7, + 'name' => 'hedera topic send message', + 'text' => 'send consensus message over hedera topic' + ],[ + 'id' => 8, + 'name' => 'hedera account create', + 'text' => 'create new account on hedera for holding some founds with unencrypted keys' + ],[ + 'id' => 9, + 'name' => 'decay start', + 'text' => 'signalize the starting point for decay calculation, allowed only once per chain' + ] + ]; + $entities = $this->newEntities($entry_contents); + $this->truncate(); + $save_results = $this->saveMany($entities); + $errors = []; + foreach($save_results as $i => $result) + { + if(!$result) { + $errors[] = $entities[$i]->getErrors(); + } + } + if(count($errors) > 0) { + return ['success' => false, 'msg' => 'error by saving transaction types', 'errors' => $errors]; + } + return ['success' => true]; + } } From 6054333929910f02e8eb4f5af5c67d1b17ba014e Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 10 May 2021 17:37:39 +0200 Subject: [PATCH 20/32] spelling & translation --- frontend/src/locales/de.json | 8 ++++---- frontend/src/locales/en.json | 4 ++-- frontend/src/views/Pages/AccountOverview/GddSend.vue | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index b297bfc81..36d761eb0 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -3,7 +3,7 @@ "welcome":"Willkommen!", "community": "Gemeinschaft", "logout":"Abmelden", - "login":"Login", + "login":"Anmeldung", "signup": "Registrieren", "reset": "Passwort zurücksetzen", "imprint":"Impressum", @@ -13,7 +13,7 @@ "back":"Zurück", "send":"Senden", "transactions":"Transaktionen", - "language":"Language", + "language":"Sprache", "languages":{ "de": "Deutsch", "en": "English" @@ -117,7 +117,7 @@ } }, "reset-password": { - "title": "Passwort Zurücksetzen", - "text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünfitg in der GRADIDO App anmelden kannst." + "title": "Passwort zurücksetzen", + "text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünftig in der Gradido-App anmelden kannst." } } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index a49d6fc3d..f9cd647c1 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -13,7 +13,7 @@ "back":"Back", "send":"Send", "transactions":"Transactions", - "language":"Sprache", + "language":"languages", "languages":{ "de": "Deutsch", "en": "English" @@ -119,6 +119,6 @@ }, "reset-password": { "title": "Reset Password", - "text": "Now you can save a new password to login to the GRADIDO App in the future." + "text": "Now you can save a new password to login to the Gradido-App in the future." } } diff --git a/frontend/src/views/Pages/AccountOverview/GddSend.vue b/frontend/src/views/Pages/AccountOverview/GddSend.vue index b262e6c34..548a7f783 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend.vue +++ b/frontend/src/views/Pages/AccountOverview/GddSend.vue @@ -184,7 +184,6 @@ {{ $t('form.close') }} -
From 394bfb71ef2325b651572fe758f98a68e9e173a4 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Mon, 10 May 2021 15:38:14 +0000 Subject: [PATCH 21/32] add missing template updates --- community_server/src/Template/Migrations/migrate.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community_server/src/Template/Migrations/migrate.ctp b/community_server/src/Template/Migrations/migrate.ctp index 6ceeec81c..4c191fb61 100644 --- a/community_server/src/Template/Migrations/migrate.ctp +++ b/community_server/src/Template/Migrations/migrate.ctp @@ -15,4 +15,4 @@

Html->link('Back to Dashboard', ['controller' => 'Dashboard', 'action' => 'index']) ?>

-); + From ffd17207660c1a9bb962a03ccfa3aeaeb53fa298 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 10 May 2021 18:01:30 +0200 Subject: [PATCH 22/32] Update frontend/src/locales/en.json Co-authored-by: Ulf Gebhardt --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index f9cd647c1..921074fbb 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -13,7 +13,7 @@ "back":"Back", "send":"Send", "transactions":"Transactions", - "language":"languages", + "language":"Language", "languages":{ "de": "Deutsch", "en": "English" From 0bb2ac0d68b08da494b4c075cf0fd10b423f2ed7 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 10 May 2021 18:06:55 +0200 Subject: [PATCH 23/32] fix: yarn test --- .../Pages/AccountOverview/GddSend.spec.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/Pages/AccountOverview/GddSend.spec.js b/frontend/src/views/Pages/AccountOverview/GddSend.spec.js index ffc8fd211..36e5d9e66 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GddSend.spec.js @@ -41,18 +41,18 @@ describe('GddSend', () => { describe('warning messages', () => { it('has a warning message', () => { - expect(wrapper.find('div.alert-warning').find('span').text()).toBe('form.attention') + expect(wrapper.find('div.alert-default').find('span').text()).toBe('form.attention') }) - it('has a dismiss button', () => { - expect(wrapper.find('div.alert-warning').find('button').exists()).toBeTruthy() - }) - - it('dismisses the warning when button is clicked', async () => { - wrapper.find('div.alert-warning').find('button').trigger('click') - await wrapper.vm.$nextTick() - expect(wrapper.find('div.alert-warning').exists()).toBeFalsy() - }) + //it('has a dismiss button', () => { + // expect(wrapper.find('div.alert-warning').find('button').exists()).toBeTruthy() + //}) +// + //it('dismisses the warning when button is clicked', async () => { + // wrapper.find('div.alert-warning').find('button').trigger('click') + // await wrapper.vm.$nextTick() + // expect(wrapper.find('div.alert-warning').exists()).toBeFalsy() + //}) }) describe('transaction form', () => { From 9965b7639f29563dbc234fd79b0558a2ab8e7a69 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 10 May 2021 18:17:37 +0200 Subject: [PATCH 24/32] fix: yarn test2 --- .../src/views/Pages/AccountOverview/GddSend.spec.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/frontend/src/views/Pages/AccountOverview/GddSend.spec.js b/frontend/src/views/Pages/AccountOverview/GddSend.spec.js index 36e5d9e66..3cd0afad0 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GddSend.spec.js @@ -43,16 +43,6 @@ describe('GddSend', () => { it('has a warning message', () => { expect(wrapper.find('div.alert-default').find('span').text()).toBe('form.attention') }) - - //it('has a dismiss button', () => { - // expect(wrapper.find('div.alert-warning').find('button').exists()).toBeTruthy() - //}) -// - //it('dismisses the warning when button is clicked', async () => { - // wrapper.find('div.alert-warning').find('button').trigger('click') - // await wrapper.vm.$nextTick() - // expect(wrapper.find('div.alert-warning').exists()).toBeFalsy() - //}) }) describe('transaction form', () => { From be26bf27587b891512067670e5a7ec150fecd61b Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Mon, 10 May 2021 17:59:34 +0000 Subject: [PATCH 25/32] tested and fixed bugs, update api docu --- .../gradido_community/transaction_types.sql | 2 +- .../src/Controller/AppController.php | 2 +- .../src/Controller/MigrationsController.php | 18 +++-- .../src/Model/Entity/StateBalance.php | 12 ++-- community_server/src/Model/Table/AppTable.php | 21 +++++- .../src/Model/Table/BlockchainTypesTable.php | 15 ++-- .../src/Model/Table/StateBalancesTable.php | 19 +++++- .../src/Model/Table/TransactionTypesTable.php | 17 ++--- .../src/Model/Table/TransactionsTable.php | 64 ++++++++--------- .../AppRequests/list_transactions.ctp | 3 + .../src/Template/Migrations/migrate.ctp | 2 +- docu/community-server.api.md | 68 +++++++++++++++++-- 12 files changed, 165 insertions(+), 78 deletions(-) diff --git a/community_server/db/skeema/gradido_community/transaction_types.sql b/community_server/db/skeema/gradido_community/transaction_types.sql index a3e6779d9..10aad25b0 100644 --- a/community_server/db/skeema/gradido_community/transaction_types.sql +++ b/community_server/db/skeema/gradido_community/transaction_types.sql @@ -1,6 +1,6 @@ CREATE TABLE `transaction_types` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL, + `name` varchar(90) COLLATE utf8mb4_unicode_ci NOT NULL, `text` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/community_server/src/Controller/AppController.php b/community_server/src/Controller/AppController.php index 80690b238..9f577d77a 100644 --- a/community_server/src/Controller/AppController.php +++ b/community_server/src/Controller/AppController.php @@ -166,7 +166,7 @@ class AppController extends Controller } $php_data_version = 2; if($current_db_version < $php_data_version) { - $this->redirect(['controller' => 'Migrations', 'action' => 'migrate', $html, $current_db_version]); + $this->redirect(['controller' => 'Migrations', 'action' => 'migrate', 'html' => $html, 'db_version' => $current_db_version]); } } diff --git a/community_server/src/Controller/MigrationsController.php b/community_server/src/Controller/MigrationsController.php index ddf02bfdc..31fa41001 100644 --- a/community_server/src/Controller/MigrationsController.php +++ b/community_server/src/Controller/MigrationsController.php @@ -13,6 +13,12 @@ use Cake\ORM\TableRegistry; */ class MigrationsController extends AppController { + public function initialize() + { + parent::initialize(); + $this->Auth->allow('migrate'); + } + /** * Index method * @@ -36,8 +42,12 @@ class MigrationsController extends AppController return ['success' => true]; } - public function migrate($html, $current_db_version) + public function migrate() { + + $html = $this->request->getQuery('html'); + $current_db_version = $this->request->getQuery('db_version'); + $startTime = microtime(true); $stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions'); $transactionsTable = TableRegistry::getTableLocator()->get('Transactions'); @@ -52,10 +62,10 @@ class MigrationsController extends AppController if($current_db_version == 1) { $stateUserTransactionsTable->truncate(); $commands = [ - [$transactionsTable, 'fillStateUserTransactions'], - [$stateBalancesTable, 'updateAllBalances'], [$blockchainTypesTable, 'fillWithDefault'], - [$transactionTypesTable, 'fillWithDefault'] + [$transactionTypesTable, 'fillWithDefault'], + [$transactionsTable, 'fillStateUserTransactions'], + [$stateBalancesTable, 'updateAllBalances'] ]; $new_db_version = 2; } diff --git a/community_server/src/Model/Entity/StateBalance.php b/community_server/src/Model/Entity/StateBalance.php index 7d595653e..334db222f 100644 --- a/community_server/src/Model/Entity/StateBalance.php +++ b/community_server/src/Model/Entity/StateBalance.php @@ -44,9 +44,7 @@ class StateBalance extends Entity } else if(method_exists($dateOrTime, 'i18nFormat')) { return $dateOrTime->i18nFormat(Time::UNIX_TIMESTAMP_FORMAT); } else { - var_dump($dateOrTime); - debug_print_backtrace(0, 6); - die("date or time unexpected object"); + return 0; } } @@ -59,8 +57,12 @@ class StateBalance extends Entity // SELECT TIMESTAMPDIFF(SECOND, modified, CURDATE()) AS age_in_seconds from state_balances // decay_for_duration = decay_factor^seconds // decay = gradido_cent * decay_for_duration - - $decay_duration = intval(Time::now()->getTimestamp() - $this->convertToTimestamp($this->record_date)); + $startDate = $this->convertToTimestamp($this->record_date); + if($startDate == 0) { + return $this->amount; + } + + $decay_duration = intval(Time::now()->getTimestamp() - $startDate); if($decay_duration === 0) { return $this->amount; } diff --git a/community_server/src/Model/Table/AppTable.php b/community_server/src/Model/Table/AppTable.php index 3a281afcc..138a7f949 100644 --- a/community_server/src/Model/Table/AppTable.php +++ b/community_server/src/Model/Table/AppTable.php @@ -1,5 +1,7 @@ schema()->truncateSql($this->connection()); + $truncateCommands = $this->getSchema()->truncateSql($this->getConnection()); foreach ($truncateCommands as $truncateCommand) { - $this->connection()->query($truncateCommand); + $this->getConnection()->query($truncateCommand); } + $this->getConnection()->query('ALTER TABLE ' . $this->getSchema()->name() . ' AUTO_INCREMENT=1'); } + public function saveManyWithErrors($entities) + { + $save_results = $this->saveMany($entities); + // save all at once failed, no try one by one to get error message + if($save_results === false) { + foreach($entities as $entity) { + if(!$this->save($entity)) { + return ['success' => false, 'errors' => $entity->getErrors()]; + } + } + } else { + return ['success' => true]; + } + } } diff --git a/community_server/src/Model/Table/BlockchainTypesTable.php b/community_server/src/Model/Table/BlockchainTypesTable.php index 252fb8fd7..3aa67a83d 100644 --- a/community_server/src/Model/Table/BlockchainTypesTable.php +++ b/community_server/src/Model/Table/BlockchainTypesTable.php @@ -84,18 +84,11 @@ class BlockchainTypesTable extends AppTable ]; $entities = $this->newEntities($entry_contents); $this->truncate(); - $save_results = $this->saveMany($entities); - $errors = []; - foreach($save_results as $i => $result) - { - if(!$result) { - $errors[] = $entities[$i]->getErrors(); - } + $save_results = $this->saveManyWithErrors($entities); + if(!$save_results['success']) { + $save_results['msg'] = 'error by saving default transaction types'; } - if(count($errors) > 0) { - return ['success' => false, 'msg' => 'error by saving blockchain types', 'errors' => $errors]; - } - return ['success' => true]; + return $save_results; } } diff --git a/community_server/src/Model/Table/StateBalancesTable.php b/community_server/src/Model/Table/StateBalancesTable.php index 87e961c5d..8ee3be193 100644 --- a/community_server/src/Model/Table/StateBalancesTable.php +++ b/community_server/src/Model/Table/StateBalancesTable.php @@ -91,25 +91,38 @@ class StateBalancesTable extends Table return $rules; } - public static function calculateDecay($startBalance, FrozenTime $startDate, FrozenTime $endDate) + public function calculateDecay($startBalance, FrozenTime $startDate, FrozenTime $endDate, $withInterval = false) { $decayStartDate = self::getDecayStartDateCached(); // if no start decay block exist, we just return input // if start date for decay is after enddate, we also just return input if($decayStartDate === null || $decayStartDate >= $endDate) { - return $startBalance; + if($withInterval) { + return ['balance' => $startBalance, 'interval' => new \DateInterval('PT0S')]; + } else { + return $startBalance; + } } $state_balance = $this->newEntity(); $state_balance->amount = $startBalance; + $interval = null; // if decay start date is before start date we calculate decay for full duration if($decayStartDate < $startDate) { $state_balance->record_date = $startDate; + $interval = $endDate->diff($startDate); } // if decay start in between start date and end date we caculcate decay from decay start time to end date else { $state_balance->record_date = $decayStartDate; + $interval = $endDate->diff($decayStartDate); } - return $state_balance->partDecay($endDate); + $decay = $state_balance->partDecay($endDate); + if($withInterval) { + return ['balance' => $decay, 'interval' => $interval]; + } else { + return $decay; + } + } diff --git a/community_server/src/Model/Table/TransactionTypesTable.php b/community_server/src/Model/Table/TransactionTypesTable.php index 7669ff2b3..2ffd1e64c 100644 --- a/community_server/src/Model/Table/TransactionTypesTable.php +++ b/community_server/src/Model/Table/TransactionTypesTable.php @@ -55,7 +55,7 @@ class TransactionTypesTable extends AppTable $validator ->scalar('name') - ->maxLength('name', 24) + ->maxLength('name', 45) ->requirePresence('name', 'create') ->notEmptyString('name'); @@ -111,17 +111,10 @@ class TransactionTypesTable extends AppTable ]; $entities = $this->newEntities($entry_contents); $this->truncate(); - $save_results = $this->saveMany($entities); - $errors = []; - foreach($save_results as $i => $result) - { - if(!$result) { - $errors[] = $entities[$i]->getErrors(); - } + $save_results = $this->saveManyWithErrors($entities); + if(!$save_results['success']) { + $save_results['msg'] = 'error by saving default transaction types'; } - if(count($errors) > 0) { - return ['success' => false, 'msg' => 'error by saving transaction types', 'errors' => $errors]; - } - return ['success' => true]; + return $save_results; } } diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 9ae2fe02a..5169129d7 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -1,12 +1,12 @@ 0 && $decay == true) - { + $prev = null; + if($i > 0 ) { $prev = $stateUserTransactions[$i-1]; + } + if($prev && $decay == true) + { + if($prev->balance > 0) { // var_dump($stateUserTransactions); $current = $su_transaction; //echo "decay between " . $prev->transaction_id . " and " . $current->transaction_id . "
"; - $interval = $current->balance_date->diff($prev->balance_date); - $state_balance->amount = $prev->balance; - $state_balance->record_date = $prev->balance_date; - $diff_amount = $state_balance->partDecay($current->balance_date); - + $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); + //echo $interval->format('%R%a days'); //echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . "
"; $final_transactions[] = [ 'type' => 'decay', - 'balance' => floatval(intval($prev->balance - $diff_amount)), - 'decay_duration' => $interval->format('%a days, %H hours, %I minutes, %S seconds'), + 'balance' => floatval($prev->balance - $calculated_decay['balance']), + 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), 'memo' => '' ]; } @@ -207,13 +208,16 @@ class TransactionsTable extends Table echo "
";*/ if($su_transaction->transaction_type_id == 1) { // creation $creation = $transaction->transaction_creation; + $balance = $stateBalancesTable->calculateDecay($creation->amount, $creation->target_date, $transaction->received); + $final_transactions[] = [ 'name' => 'Gradido Akademie', 'type' => 'creation', 'transaction_id' => $transaction->id, 'date' => $transaction->received,// $creation->target_date, 'target_date' => $creation->target_date, - 'balance' => $creation->amount, + 'creation_amount' => $creation->amount, + 'balance' => $balance, 'memo' => $transaction->memo ]; } else if($su_transaction->transaction_type_id == 2) { // transfer or send coins @@ -253,12 +257,18 @@ class TransactionsTable extends Table } if($i == $stateUserTransactionsCount-1 && $decay == true) { - $state_balance->amount = $su_transaction->balance; - $state_balance->record_date = $su_transaction->balance_date; + $calculated_decay = $stateBalancesTable->calculateDecay( + $su_transaction->balance, + $su_transaction->balance_date, new FrozenTime(), true); + $decay_start_date = $stateBalancesTable->getDecayStartDateCached(); + $duration = $su_transaction->balance_date->timeAgoInWords(); + if($decay_start_date > $su_transaction->balance_date) { + $duration = $decay_start_date->timeAgoInWords(); + } $final_transactions[] = [ 'type' => 'decay', - 'balance' => floatval(intval($su_transaction->balance - $state_balance->decay)), - 'decay_duration' => $su_transaction->balance_date->timeAgoInWords(), + 'balance' => floatval($su_transaction->balance - $calculated_decay['balance']), + 'decay_duration' => $duration, 'memo' => '' ]; } @@ -337,12 +347,13 @@ class TransactionsTable extends Table } public function fillStateUserTransactions() - { + { $missing_transaction_ids = []; $transaction_ids = $this ->find('all') ->select(['id', 'transaction_type_id']) ->order(['id']) + ->where(['transaction_type_id <' => 6]) ->all() ; $state_user_transaction_ids = $this->StateUserTransactions @@ -422,21 +433,10 @@ class TransactionsTable extends Table } } - $results = $this->StateUserTransactions->saveMany($finalEntities); - $errors = []; - foreach($results as $i => $res) { - if($res == false) { - $errors[] = $finalEntities[$i]->getErrors(); - } + $save_results = $this->StateUserTransactions->saveManyWithErrors($finalEntities); + if(!$save_results['success']) { + $save_results['msg'] = 'error by saving at least one state user transaction'; } - if(count($errors) == 0) { - $result = ['success' => true]; - } else { - $result = ['success' => false, 'msg' => 'error by saving at least one state user transaction', 'errors' => $errors]; - } - - - - return $result; + return $save_results; } } diff --git a/community_server/src/Template/AppRequests/list_transactions.ctp b/community_server/src/Template/AppRequests/list_transactions.ctp index f829b5f16..28a76f2be 100644 --- a/community_server/src/Template/AppRequests/list_transactions.ctp +++ b/community_server/src/Template/AppRequests/list_transactions.ctp @@ -12,6 +12,9 @@ $body['gdtSum'] = $this->element('centToFloat', ['cent' => $body['gdtSum'], 'pre foreach($body['transactions'] as $i => $transaction) { $body['transactions'][$i]['balance'] = $this->element('centToFloat', ['cent' => $transaction['balance'], 'precision' => 4]); + if(isset($transaction['creation_amount'])) { + $body['transactions'][$i]['creation_amount'] = $this->element('centToFloat', ['cent' => $transaction['creation_amount'], 'precision' => 4]); + } } ?> \ No newline at end of file diff --git a/community_server/src/Template/Migrations/migrate.ctp b/community_server/src/Template/Migrations/migrate.ctp index 4c191fb61..d345c9a90 100644 --- a/community_server/src/Template/Migrations/migrate.ctp +++ b/community_server/src/Template/Migrations/migrate.ctp @@ -10,7 +10,7 @@

Migrate from Version

Success

- +

Error

diff --git a/docu/community-server.api.md b/docu/community-server.api.md index 9354bf232..5685c9586 100644 --- a/docu/community-server.api.md +++ b/docu/community-server.api.md @@ -23,13 +23,13 @@ Additional session can be provided as GET-Parameter ```json { "state":"success", - "balance":1590.60, + "balance":15906078, "decay":15873851, "decay_date":"2021-04-16T11:47:21+00:00" } ``` -- `balance` : balance describes gradido +- `balance` : balance describes gradido cents which are 4 digits behind the separator. A balance value of 174500 equals therefor 17,45 GDD - `decay` : balance with decay on it at the time in decay_date, so it is the precise balance of user at time of calling this function - `decay_date`: date and time for decay amount, should be the time and date of function call @@ -59,16 +59,32 @@ Assuming: session is valid { "state":"success", "transactions": [ + { + "type": "decay", + "balance": "14.74", + "decay_duration": "4 days, 2 hours ago", + "memo": "" + }, { "name": "Max Mustermann", "email": "Maxim Mustermann", "type": "send", "transaction_id": 2, "date": "2021-02-19T13:25:36+00:00", - "balance": 192.0, + "balance": 192, "memo": "a piece of cake :)", "pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7" - } + }, + { + "name": "Gradido Akademie", + "type": "creation", + "transaction_id": 10, + "date": "2021-04-15T11:19:45+00:00", + "target_date": "2021-02-01T00:00:00+00:00", + "creation_amount": "1000", + "balance": "1000", + "memo": "AGE Februar 2021" + } ], "transactionExecutingCount": 0, "count": 1, @@ -95,8 +111,11 @@ Transaction: - `receiver`: user has received gradidos from another user - `transaction_id`: id of transaction in db, in stage2 also the hedera sequence number of transaction - `date`: date of ordering transaction (booking date) -- `balance`: Gradido +- `balance`: Gradido as float, max 2 Nachkommastellen, by creation balance after subtract decay amount - `memo`: Details about transaction +- `decay_duration`: only for decay, time duration for decay calculation in english text +- `creation_amount`: only for creation transaction, created account before decay +- `target_date`: only by creation transaction, target date for creation, start time for decay calculation (if < as global decay start time) ## Creation transaction Makes a creation transaction to create new Gradido @@ -150,7 +169,6 @@ with - `session_id`: optional, only used if cookie GRADIDO_LOGIN not exist and no sesion_id in php session - `email` or `username` or `pubkey`: used to identify how gets the gradidos (email and username are only aliases for pubkey) - `amount`: gdd amount to transfer in gradido cent (10000000 = 1000,00 GDD) -- `target_date`: target date for creation, can be max 3 months before current date, but not after current date, allowed formats do you find here: https://pocoproject.org/docs/Poco.DateTimeFormat.html - `memo`: text for receiver, currently saved as clear text in blockchain - `auto_sign`: if set to true, transaction will be directly signed on login-server and proceed if needed signs are there if set to false, transaction must be signed after on `http://localhost/account/checkTransactions` @@ -245,3 +263,41 @@ Without auto-sign the transaction is pending on the login-server and waits for t // TODO Is this in line with our usability goals? // TODO Should this not be handled client side? + +# Klicktipp + +## Subscribe +Subscribe current logged in user to gradido newsletter + +### Request +`GET http://localhost/api/klicktipp_subscribe/[session_id]` +Parts symbolized by [] are optional + - session_id: session will be searched in php session and GRADIDO_LOGIN cookie and if not found use this + +### Response +Assuming: session is valid + +```json +{ + "state": "success", + "redirect_url": "" +} +```` + +## Unsubscribe +Unsubscribe current logged in user from gradido newsletter + +### Request +`GET http://localhost/api/klicktipp_unsubscribe/[session_id]` +Parts symbolized by [] are optional + - session_id: session will be searched in php session and GRADIDO_LOGIN cookie and if not found use this + +### Response +Assuming: session is valid + +```json +{ + "state": "success" +} +```` + From 2dff5bdf314f0793a707117bfc1a1c9df3760876 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 10 May 2021 20:14:14 +0200 Subject: [PATCH 26/32] update docu --- docu/community-server.api.md | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/docu/community-server.api.md b/docu/community-server.api.md index 5685c9586..11556513b 100644 --- a/docu/community-server.api.md +++ b/docu/community-server.api.md @@ -23,13 +23,13 @@ Additional session can be provided as GET-Parameter ```json { "state":"success", - "balance":15906078, - "decay":15873851, + "balance":1590.60, + "decay":1587.38, "decay_date":"2021-04-16T11:47:21+00:00" } ``` -- `balance` : balance describes gradido cents which are 4 digits behind the separator. A balance value of 174500 equals therefor 17,45 GDD +- `balance` : balance describes gradido as float with max two decimal places - `decay` : balance with decay on it at the time in decay_date, so it is the precise balance of user at time of calling this function - `decay_date`: date and time for decay amount, should be the time and date of function call @@ -59,32 +59,32 @@ Assuming: session is valid { "state":"success", "transactions": [ - { - "type": "decay", - "balance": "14.74", - "decay_duration": "4 days, 2 hours ago", - "memo": "" - }, + { + "type": "decay", + "balance": "14.74", + "decay_duration": "4 days, 2 hours ago", + "memo": "" + }, { "name": "Max Mustermann", "email": "Maxim Mustermann", "type": "send", "transaction_id": 2, "date": "2021-02-19T13:25:36+00:00", - "balance": 192, + "balance": 192.0, "memo": "a piece of cake :)", "pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7" }, - { - "name": "Gradido Akademie", - "type": "creation", - "transaction_id": 10, - "date": "2021-04-15T11:19:45+00:00", - "target_date": "2021-02-01T00:00:00+00:00", - "creation_amount": "1000", - "balance": "1000", - "memo": "AGE Februar 2021" - } + { + "name": "Gradido Akademie", + "type": "creation", + "transaction_id": 10, + "date": "2021-04-15T11:19:45+00:00", + "target_date": "2021-02-01T00:00:00+00:00", + "creation_amount": "1000.0", + "balance": "1000.0", + "memo": "AGE Februar 2021" + } ], "transactionExecutingCount": 0, "count": 1, @@ -136,7 +136,7 @@ with { "session_id" : -127182, "email": "max.musterman@gmail.de", - "amount": 10000000, + "amount": 1000.0, "target_date":"2021-02-19T13:25:36+00:00", "memo":"AGE", "auto_sign": true @@ -147,7 +147,7 @@ with { "session_id" : -127182, "username": "Maxi_786", - "amount": 10000000, + "amount": 1000.0, "target_date":"2021-02-19T13:25:36+00:00", "memo":"AGE", "auto_sign": true @@ -158,7 +158,7 @@ with { "session_id" : -127182, "pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7", - "amount": 10000000, + "amount": 1000.0, "target_date":"2021-02-19T13:25:36+00:00", "memo":"AGE", "auto_sign": true @@ -168,7 +168,7 @@ with - `session_id`: optional, only used if cookie GRADIDO_LOGIN not exist and no sesion_id in php session - `email` or `username` or `pubkey`: used to identify how gets the gradidos (email and username are only aliases for pubkey) -- `amount`: gdd amount to transfer in gradido cent (10000000 = 1000,00 GDD) +- `amount`: gdd amount to transfer in gradido as float - `memo`: text for receiver, currently saved as clear text in blockchain - `auto_sign`: if set to true, transaction will be directly signed on login-server and proceed if needed signs are there if set to false, transaction must be signed after on `http://localhost/account/checkTransactions` @@ -204,7 +204,7 @@ with { "session_id" : -127182, "email": "max.musterman@gmail.de", - "amount": 1000000, + "amount": 100.0, "memo":"a gift", "auto_sign": true } @@ -214,7 +214,7 @@ with { "session_id" : -127182, "username": "Maxi_786", - "amount": 1000000, + "amount": 100.0, "memo":"a gift", "auto_sign": true } @@ -224,13 +224,13 @@ with { "session_id" : -127182, "pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7", - "amount": 1000000, + "amount": 100.0, "memo":"a gift", "auto_sign": true } ``` - `session_id`: optional, only used if cookie GRADIDO_LOGIN not exist and no sesion_id in php session -- `amount`: amount to transfer, 2000000 = 200,00 GDD +- `amount`: amount to transfer as float - `email` or `username` or `pubkey`: used to identify how gets the gradidos (email and username are only aliases for pubkey) - `memo`: text for receiver, currently saved as clear text in blockchain - `auto_sign`: if set to true, transaction will be directly signed on login-server and proceed if needed signs are there From f8e8b6e56e4b44b2e3f7e5a90f431c1257464fc8 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 10 May 2021 20:17:10 +0200 Subject: [PATCH 27/32] ignore netbeans project files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c8c581e51..44f403757 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /node_modules/* .vscode .skeema +nbproject \ No newline at end of file From 4733944f2fbbf80ca5be379347089193b84c47f4 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Mon, 10 May 2021 18:57:10 +0000 Subject: [PATCH 28/32] fix bug in merged code --- .../src/Model/Table/TransactionsTable.php | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 3bccb7bbf..742ce7882 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -184,21 +184,21 @@ class TransactionsTable extends Table $current = $su_transaction; //echo "decay between " . $prev->transaction_id . " and " . $current->transaction_id . "
"; $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); - $balance = floatval($prev->balance - $diff_amount); + $balance = floatval($prev->balance - $calculated_decay['balance']); // skip small decays (smaller than 0,00 GDD) if(abs($balance) >= 100) { - //echo $interval->format('%R%a days'); - //echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . "
"; - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => floatval($prev->balance - $calculated_decay['balance']), - 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), - 'memo' => '' - ]; + //echo $interval->format('%R%a days'); + //echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . "
"; + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), + 'memo' => '' + ]; + } } } - } // sender or receiver when user has sended money // group name if creation @@ -269,17 +269,17 @@ class TransactionsTable extends Table if($decay_start_date > $su_transaction->balance_date) { $duration = $decay_start_date->timeAgoInWords(); } - $balance = floatval($su_transaction->balance - $state_balance->decay); + $balance = floatval($su_transaction->balance - $calculated_decay['balance']); if($balance > 100) { - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => floatval($su_transaction->balance - $calculated_decay['balance']), - 'decay_duration' => $duration, - 'memo' => '' - ]; + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $duration, + 'memo' => '' + ]; + } } } - } return $final_transactions; From 986f40cf5369563d8d2430db53ac4a29cd38d470 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 11 May 2021 07:24:59 +0200 Subject: [PATCH 29/32] transaction error message, translations --- frontend/src/locales/de.json | 8 ++-- frontend/src/locales/en.json | 14 ++++--- .../views/Pages/AccountOverview/GddSend.vue | 38 +++++++++++++++---- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 36d761eb0..97b751019 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -41,10 +41,12 @@ "time":"Zeit", "send_now":"Jetzt versenden", "scann_code":"QR Code Scanner - Scanne den QR Code deines Partners", - "max_gdd_info":"maximale anzahl GDD zum versenden erreicht!", + "max_gdd_info":"Maximale anzahl GDD zum versenden erreicht!", "send_check":"Bestätige deine Zahlung. Prüfe bitte nochmal alle Daten!", - "thx":"Danke,", - "send_success":"deine Transaktion wurde erfolgreich ausgeführt" + "thx":"Danke", + "sorry":"Entschuldigung", + "send_transaction_success":"Deine Transaktion wurde erfolgreich ausgeführt", + "send_transaction_error":"Leider konnte die Transaktion nicht ausgeführt werden!" }, "error": { "error":"Fehler" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 921074fbb..f3a4a1dfb 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -19,7 +19,7 @@ "en": "English" }, "form": { - "attention": "Achtung! Bitte überprüfe alle deine Eingaben sehr genau. Du bist alleine Verantwortlich für deine Entscheidungen. Versendete Gradidos können nicht wieder zurück geholt werden.", + "attention": "Attention! Please check all your entries very carefully. You are solely responsible for your decisions. Sent Gradidos cannot be retrieved.", "cancel":"Cancel", "reset": "Reset", "close":"Close", @@ -40,11 +40,13 @@ "at":"at", "time":"Time", "send_now":"Send now", - "scann_code":"QR Code Scanner - Scanne den QR Code deines Partners", - "max_gdd_info":"maximale anzahl GDD zum versenden erreicht!", - "send_check":"Bestätige deine Zahlung. Prüfe bitte nochmal alle Daten!", - "thx":"Thank you,", - "send_success":"your transaction was successfully completed" + "scann_code":"QR Code Scanner - Scan the QR Code of your partner", + "max_gdd_info":"Maximum number of GDDs to be sent has been reached!", + "send_check":"Confirm your payment. Please check all data again!", + "thx":"Thank you", + "sorry":"Sorry", + "send_transaction_success":"Your transaction was successfully completed", + "send_transaction_error":"Unfortunately, the transaction could not be executed!" }, "error": { "error":"Error" diff --git a/frontend/src/views/Pages/AccountOverview/GddSend.vue b/frontend/src/views/Pages/AccountOverview/GddSend.vue index 648216ab8..9053d0ea4 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend.vue +++ b/frontend/src/views/Pages/AccountOverview/GddSend.vue @@ -179,13 +179,31 @@ -
- {{ $t('form.thx') }} -
- {{ $t('form.send_success') }} -
+ +
+ {{ $t('form.thx') }} +
+ {{ $t('form.send_transaction_success') }} +
- {{ $t('form.close') }} +

+ {{ $t('form.close') }} +

+
+
+
+ + + +
+ {{ $t('form.sorry') }} +
+ {{ $t('form.send_transaction_error') }} +
+

+ {{ $t('form.close') }} +

+
@@ -226,7 +244,8 @@ export default { }, send: false, row_check: false, - row_thx: false, + row_thx: true, + row_error: false, } }, computed: {}, @@ -250,6 +269,7 @@ export default { this.$emit('toggle-show-list', false) this.row_check = true this.row_thx = false + this.row_error = false }, async sendTransaction() { const result = await communityAPI.send( @@ -263,12 +283,13 @@ export default { this.$emit('toggle-show-list', false) this.row_check = false this.row_thx = true + this.row_error = false this.$emit('update-balance', { ammount: this.ajaxCreateData.amount }) } else { - alert('error') this.$emit('toggle-show-list', true) this.row_check = false this.row_thx = false + this.row_error = true } }, onReset(event) { @@ -280,6 +301,7 @@ export default { this.$emit('toggle-show-list', true) this.row_check = false this.row_thx = false + this.row_error = false this.$nextTick(() => { this.show = true }) From 2d665299c7db2325366c25d8c6bf09a0301aa5dd Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 11 May 2021 11:32:39 +0200 Subject: [PATCH 30/32] use setBaseUrl function instead of hacking getLink function --- login_server/src/cpp/JSONInterface/JsonCreateUser.cpp | 2 +- login_server/src/cpp/JSONInterface/JsonRequestHandler.cpp | 8 +++++++- login_server/src/cpp/JSONInterface/JsonRequestHandler.h | 1 + login_server/src/cpp/JSONInterface/JsonSendEmail.cpp | 6 ++++-- login_server/src/cpp/controller/EmailVerificationCode.cpp | 3 --- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp b/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp index c66d10c8d..4917f611a 100644 --- a/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp +++ b/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp @@ -109,7 +109,7 @@ Poco::JSON::Object* JsonCreateUser::handle(Poco::Dynamic::Var params) emailOptInModel->sendErrorsAsEmail(); return stateError("insert emailOptIn failed"); } - + emailOptIn->setBaseUrl(mServerHost + "/" + ServerConfig::g_frontend_checkEmailPath); em->addEmail(new model::Email(emailOptIn, user, model::Email::convertTypeFromInt(emailType))); if (login_after_register && session) { diff --git a/login_server/src/cpp/JSONInterface/JsonRequestHandler.cpp b/login_server/src/cpp/JSONInterface/JsonRequestHandler.cpp index 99b4eb0fe..a577155b9 100644 --- a/login_server/src/cpp/JSONInterface/JsonRequestHandler.cpp +++ b/login_server/src/cpp/JSONInterface/JsonRequestHandler.cpp @@ -43,7 +43,13 @@ void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Po //std::ostream& responseStream = _compressResponse ? _gzipStream : _responseStream; mClientIp = request.clientAddress().host(); - + + if (request.secure()) { + mServerHost = "https://" + request.getHost(); + } + else { + mServerHost = "http://" + request.getHost(); + } auto method = request.getMethod(); std::istream& request_stream = request.stream(); Poco::JSON::Object* json_result = nullptr; diff --git a/login_server/src/cpp/JSONInterface/JsonRequestHandler.h b/login_server/src/cpp/JSONInterface/JsonRequestHandler.h index ed0272ac8..834ac512e 100644 --- a/login_server/src/cpp/JSONInterface/JsonRequestHandler.h +++ b/login_server/src/cpp/JSONInterface/JsonRequestHandler.h @@ -26,6 +26,7 @@ public: protected: Poco::JSON::Object* mResultJson; Poco::Net::IPAddress mClientIp; + std::string mServerHost; Session* mSession; Poco::JSON::Object* checkAndLoadSession(Poco::Dynamic::Var params, bool checkIp = false); diff --git a/login_server/src/cpp/JSONInterface/JsonSendEmail.cpp b/login_server/src/cpp/JSONInterface/JsonSendEmail.cpp index 9228c31cb..3179d81ce 100644 --- a/login_server/src/cpp/JSONInterface/JsonSendEmail.cpp +++ b/login_server/src/cpp/JSONInterface/JsonSendEmail.cpp @@ -105,12 +105,12 @@ Poco::JSON::Object* JsonSendEmail::handle(Poco::Dynamic::Var params) return stateError("invalid email"); } auto receiver_user_id = receiver_user->getModel()->getID(); - + std::string checkEmailUrl = receiver_user->getGroupBaseUrl() + ServerConfig::g_frontend_checkEmailPath; if (emailVerificationCodeType == model::table::EMAIL_OPT_IN_RESET_PASSWORD) { session = sm->getNewSession(); if (emailType == model::EMAIL_USER_RESET_PASSWORD) { - auto r = session->sendResetPasswordEmail(receiver_user, true, receiver_user->getGroupBaseUrl()); + auto r = session->sendResetPasswordEmail(receiver_user, true, checkEmailUrl); if (1 == r) { return stateWarning("email already sended"); } @@ -120,6 +120,7 @@ Poco::JSON::Object* JsonSendEmail::handle(Poco::Dynamic::Var params) } else if (emailType == model::EMAIL_CUSTOM_TEXT) { auto email_verification_code_object = controller::EmailVerificationCode::loadOrCreate(receiver_user_id, model::table::EMAIL_OPT_IN_RESET_PASSWORD); + email_verification_code_object->setBaseUrl(checkEmailUrl); auto email = new model::Email(email_verification_code_object, receiver_user, emailCustomText, emailCustomSubject); em->addEmail(email); } @@ -135,6 +136,7 @@ Poco::JSON::Object* JsonSendEmail::handle(Poco::Dynamic::Var params) } auto email_verification_code_object = controller::EmailVerificationCode::loadOrCreate(receiver_user_id, emailVerificationCodeType); + email_verification_code_object->setBaseUrl(checkEmailUrl); model::Email* email = nullptr; if (emailType == model::EMAIL_CUSTOM_TEXT) { email = new model::Email(email_verification_code_object, receiver_user, emailCustomText, emailCustomSubject); diff --git a/login_server/src/cpp/controller/EmailVerificationCode.cpp b/login_server/src/cpp/controller/EmailVerificationCode.cpp index 77384c209..16fcefbb8 100644 --- a/login_server/src/cpp/controller/EmailVerificationCode.cpp +++ b/login_server/src/cpp/controller/EmailVerificationCode.cpp @@ -122,9 +122,6 @@ namespace controller { std::string EmailVerificationCode::getLink() { std::string link = mBaseUrl; - if (ServerConfig::g_frontend_checkEmailPath.size() > 1) { - link = ServerConfig::g_frontend_checkEmailPath; - } if (link.data()[link.size() - 1] != '/') { link += '/'; From 2417cfa6ee5220e39e7ebeaa2a436c17eed17cb6 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Tue, 11 May 2021 09:42:51 +0000 Subject: [PATCH 31/32] add Ulfs suggestion --- community_server/src/Model/Table/StateBalancesTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community_server/src/Model/Table/StateBalancesTable.php b/community_server/src/Model/Table/StateBalancesTable.php index 8ee3be193..7e5f96be9 100644 --- a/community_server/src/Model/Table/StateBalancesTable.php +++ b/community_server/src/Model/Table/StateBalancesTable.php @@ -189,7 +189,7 @@ class StateBalancesTable extends Table $last_state_user_transaction->balance_date, $now); // if entrys are nearly the same, we don't need doing anything - if(abs($last_state_user_transaction_decayed - $first_state_balance_decayed) > 100) { + if(floor($last_state_user_transaction_decayed/100) !== floor($first_state_balance_decayed/100)) { $recalculate_state_user_transactions_balance = true; $update_state_balance = true; } From 1bc7bd66fdf1ffdeebfb3930d84a5a339557d063 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 11 May 2021 12:05:14 +0200 Subject: [PATCH 32/32] =?UTF-8?q?docu:=20locales=20sch=C3=B6pfen-mysql=20b?= =?UTF-8?q?efehl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docu/other/mariadb_groups_insert.md | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 docu/other/mariadb_groups_insert.md diff --git a/docu/other/mariadb_groups_insert.md b/docu/other/mariadb_groups_insert.md new file mode 100644 index 000000000..3bb61ab0b --- /dev/null +++ b/docu/other/mariadb_groups_insert.md @@ -0,0 +1,30 @@ +# Das Locale Schöpfen + +### MariaDB Insert Groups + +wenn local geschöpft werden möchte kommt ein fehler das der user keiner gruppe zugeordnet ist. + +folgende schritte musst du machen um eine gruppe anzulegen + +hier findest du den Mysql befehl: configs/login_server/setup_db_tables/setup_docker_group.sql +in der Datei findest du folgenden Befehl + + INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `host`, `home`, `description`) VALUES + (1, 'docker', 'docker gradido group', 'localhost', 'nginx', '/', 'gradido test group for docker and stage2 with blockchain db'); + +# Ablauf + +1. logge dich bei phpmyadmin ein http://localhost:8074/ (mariadb / root) +2. gehe auf tabelle "gradido_login" +3. gib folgenden Befehl in die console ein + + INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `host`, `home`, `description`) VALUES + (1, 'docker', 'docker gradido group', 'localhost', 'nginx', '/', 'gradido test group for docker and stage2 with blockchain db'); + +> es wird eine Gruppe mit id 1 angelgt. alle angelegten user sollten dieser gruppe zugeordnet sein. + +das schöpfen sollte nun local funktionieren. :) + + + +#ACHTUNG ! nach dem login kann noch zu fehlern kommen in der URL "localhostnginx/..." zu "localhost/..." ändern \ No newline at end of file