diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f9f98748e..cf0b061ef 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -50,7 +50,7 @@ jobs:
##########################################################################
- name: login server | Build `test` image
run: |
- docker build --target login_server_debug -t "gradido/login_server:test" -f ./login_server/Dockerfile.debug login_server/
+ docker build --target login_server -t "gradido/login_server:test" -f ./login_server/Dockerfile login_server/
docker save "gradido/login_server:test" > /tmp/login_server.tar
- name: Upload Artifact
uses: actions/upload-artifact@v2
@@ -212,7 +212,7 @@ jobs:
report_name: Coverage Frontend
type: lcov
result_path: ./coverage/lcov.info
- min_coverage: 15
+ min_coverage: 19
token: ${{ github.token }}
#test:
diff --git a/.gitignore b/.gitignore
index 5c23ad8bd..6c67d7f9c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
*.log
/node_modules/*
.vscode
+messages.pot
+.skeema
+nbproject
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
index 7ebe00a4d..62e643b38 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -27,5 +27,10 @@
[submodule "community_server/src/protobuf"]
path = community_server/src/protobuf
- url = git@github.com:gradido/gradido_protocol.git
-
+ url = https://github.com/gradido/gradido_protocol.git
+[submodule "login_server/dependencies/libsodium"]
+ path = login_server/dependencies/libsodium
+ url = https://github.com/jedisct1/libsodium.git
+[submodule "login_server/src/proto"]
+ path = login_server/src/proto
+ url = https://github.com/gradido/gradido_protocol.git
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8c943ecd9..6b03c78d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,8 +4,138 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
+#### [1.0.1](https://github.com/gradido/gradido/compare/1.0.0...1.0.1)
+
+- add try catch blocks to prevent login-server from crashing [`22ff220`](https://github.com/gradido/gradido/commit/22ff22072956f8b843037c75c5b16b7ff5d6a2a3)
+- fix [`14a4243`](https://github.com/gradido/gradido/commit/14a424347817b1fe6912a113bffd70e55d688112)
+
+### [1.0.0](https://github.com/gradido/gradido/compare/0.9.4...1.0.0)
+
+> 14 May 2021
+
+- Login build alpine [`#423`](https://github.com/gradido/gradido/pull/423)
+- Release fix [`#428`](https://github.com/gradido/gradido/pull/428)
+- Send button only click [`#427`](https://github.com/gradido/gradido/pull/427)
+- use new function for balance overview in old frontend, update balance… [`#422`](https://github.com/gradido/gradido/pull/422)
+- thx.vue coloured background removed. design adapted to app [`#426`](https://github.com/gradido/gradido/pull/426)
+- translation password rules in Register.vue and ResetPasswort.vue fixed [`#424`](https://github.com/gradido/gradido/pull/424)
+- 06x style [`#419`](https://github.com/gradido/gradido/pull/419)
+- feat: Dash is Shown When Balance is Loading [`#396`](https://github.com/gradido/gradido/pull/396)
+- refactor: Split GddSend into Components [`#415`](https://github.com/gradido/gradido/pull/415)
+- fix: Set Maximum Transactions Loaded to 1000 [`#395`](https://github.com/gradido/gradido/pull/395)
+- BUG : preRELEASE : thx transaction false [`#394`](https://github.com/gradido/gradido/pull/394)
+- feat: Validation of Input Fields of GddSend [`#386`](https://github.com/gradido/gradido/pull/386)
+- add validation, check if user has tried to send themself gradidos [`#277`](https://github.com/gradido/gradido/pull/277)
+- fix link generation [`#347`](https://github.com/gradido/gradido/pull/347)
+- Community start decay [`#387`](https://github.com/gradido/gradido/pull/387)
+- transaction error message, translations [`#388`](https://github.com/gradido/gradido/pull/388)
+- docu: locales schöpfen-mysql befehl [`#392`](https://github.com/gradido/gradido/pull/392)
+- Fix: QR Scanner Hide [`#380`](https://github.com/gradido/gradido/pull/380)
+- change design- dark-blue of text-ligth [`#381`](https://github.com/gradido/gradido/pull/381)
+- spelling & translation [`#385`](https://github.com/gradido/gradido/pull/385)
+- 350 6 login [`#383`](https://github.com/gradido/gradido/pull/383)
+- fix: breakout error [`#375`](https://github.com/gradido/gradido/pull/375)
+- 233-Support-Button fix, and col error fix [`#343`](https://github.com/gradido/gradido/pull/343)
+- fix: membersarea open in a new tap [`#370`](https://github.com/gradido/gradido/pull/370)
+- 00x table footer componente [`#345`](https://github.com/gradido/gradido/pull/345)
+- clickevent from icon to button [`#364`](https://github.com/gradido/gradido/pull/364)
+- 404 link to login page fix [`#366`](https://github.com/gradido/gradido/pull/366)
+- bug: session_id vs sessionId [`#365`](https://github.com/gradido/gradido/pull/365)
+- eslint rule standard [`#344`](https://github.com/gradido/gradido/pull/344)
+- don't show decays smaller than 0,01 GDD [`#329`](https://github.com/gradido/gradido/pull/329)
+- 338 - mt-5 margin top 5 eingebunden [`#341`](https://github.com/gradido/gradido/pull/341)
+- feat: Update Transactions When GddTable Is Rendered [`#339`](https://github.com/gradido/gradido/pull/339)
+- my profile auskommentiert [`#337`](https://github.com/gradido/gradido/pull/337)
+- give balance as float value in GDD (not longer GDD cent) [`#273`](https://github.com/gradido/gradido/pull/273)
+- fix error with password reset email [`#276`](https://github.com/gradido/gradido/pull/276)
+- transaction.show_all in en.json hinzugefügt [`#335`](https://github.com/gradido/gradido/pull/335)
+- refactor: Add Paramerts to ListTransactions API Call [`#332`](https://github.com/gradido/gradido/pull/332)
+- css abstände vom rand in mobilen style [`#272`](https://github.com/gradido/gradido/pull/272)
+- error messages are displayed [`#304`](https://github.com/gradido/gradido/pull/304)
+- cancel to reset, form rest event added [`#334`](https://github.com/gradido/gradido/pull/334)
+- remove from error messages because its no longer exist [`#330`](https://github.com/gradido/gradido/pull/330)
+- xx deleted [`#333`](https://github.com/gradido/gradido/pull/333)
+- fix bug on Login group add host [`#274`](https://github.com/gradido/gradido/pull/274)
+- transactionslist load and icon [`#324`](https://github.com/gradido/gradido/pull/324)
+- THX changed to Thank you [`#305`](https://github.com/gradido/gradido/pull/305)
+- fix_bug_template [`#284`](https://github.com/gradido/gradido/pull/284)
+- feat: Restructure Overview [`#271`](https://github.com/gradido/gradido/pull/271)
+- fix: Dynamic Balance in User Profile [`#278`](https://github.com/gradido/gradido/pull/278)
+- refactor: Test and Clean Up Store [`#270`](https://github.com/gradido/gradido/pull/270)
+- remove links to not work [`#267`](https://github.com/gradido/gradido/pull/267)
+- change order of session_id [`#269`](https://github.com/gradido/gradido/pull/269)
+- bug: Dynamic Balance [`#260`](https://github.com/gradido/gradido/pull/260)
+- Fix problems with transactions in docker environment [`#261`](https://github.com/gradido/gradido/pull/261)
+- update skeema call to allow also for unsafe db updates [`#250`](https://github.com/gradido/gradido/pull/250)
+- turn registration on and off [`#266`](https://github.com/gradido/gradido/pull/266)
+- 243 vue loader component - varante 2 [`#257`](https://github.com/gradido/gradido/pull/257)
+- fix_issue_templates [`#262`](https://github.com/gradido/gradido/pull/262)
+- fix_nginx_docker [`#253`](https://github.com/gradido/gradido/pull/253)
+- 13_coverage [`#255`](https://github.com/gradido/gradido/pull/255)
+- add language as fields which will be returned with user-object [`#244`](https://github.com/gradido/gradido/pull/244)
+- add short description for target date in creation transaction [`#252`](https://github.com/gradido/gradido/pull/252)
+- fix error "Integrity constraint violation: 1052 Column 'id' in where … [`#251`](https://github.com/gradido/gradido/pull/251)
+- Clicks on button [`#246`](https://github.com/gradido/gradido/pull/246)
+- Change css [`#231`](https://github.com/gradido/gradido/pull/231)
+- feat: Reset Password [`#212`](https://github.com/gradido/gradido/pull/212)
+- fix bug #221 [`#228`](https://github.com/gradido/gradido/pull/228)
+- fix empty reply by empty group_id [`#227`](https://github.com/gradido/gradido/pull/227)
+- Bugfix 22 04 21 [`#226`](https://github.com/gradido/gradido/pull/226)
+- Rollback use prebuild dependencies [`#225`](https://github.com/gradido/gradido/pull/225)
+- Docu [`#199`](https://github.com/gradido/gradido/pull/199)
+- update login-server build [`#222`](https://github.com/gradido/gradido/pull/222)
+- Login add language [`#220`](https://github.com/gradido/gradido/pull/220)
+- User Object on Json Login [`#219`](https://github.com/gradido/gradido/pull/219)
+- refactor: Remove loginAPI Call from Store [`#215`](https://github.com/gradido/gradido/pull/215)
+- fix: Remove Rules for Password on Login [`#214`](https://github.com/gradido/gradido/pull/214)
+- Community 15 04 2021 [`#198`](https://github.com/gradido/gradido/pull/198)
+- refactor: Remove Right Menu [`#204`](https://github.com/gradido/gradido/pull/204)
+- feat: Raise Frontend Test Coverage to 12% [`#206`](https://github.com/gradido/gradido/pull/206)
+- refactor: Remove Cookies [`#202`](https://github.com/gradido/gradido/pull/202)
+- fix_docker_compose [`#205`](https://github.com/gradido/gradido/pull/205)
+- 62 pwd reset [`#203`](https://github.com/gradido/gradido/pull/203)
+- workflows_refactor [`#200`](https://github.com/gradido/gradido/pull/200)
+- feat: Link to Whitepaper in Content-Footer [`#196`](https://github.com/gradido/gradido/pull/196)
+- update code which produce error which last fix (._.); [`#197`](https://github.com/gradido/gradido/pull/197)
+- refactor: Redirects and Misuse of Children in Router [`#194`](https://github.com/gradido/gradido/pull/194)
+- fix: Gradido-Akademie in Footer Links to gradido.net [`#170`](https://github.com/gradido/gradido/pull/170)
+- fix register [`#160`](https://github.com/gradido/gradido/pull/160)
+- Login 14.04.21 [`#175`](https://github.com/gradido/gradido/pull/175)
+- coverage_no_report [`#176`](https://github.com/gradido/gradido/pull/176)
+- Community 14.04.21 [`#174`](https://github.com/gradido/gradido/pull/174)
+- feat: Add Coverage Check To GitHub Workflow [`#158`](https://github.com/gradido/gradido/pull/158)
+- Stage2 [`#49`](https://github.com/gradido/gradido/pull/49)
+- feat: Unit Test for KontoOverview [`#169`](https://github.com/gradido/gradido/pull/169)
+- fix: Remove Hashtag From Route [`#167`](https://github.com/gradido/gradido/pull/167)
+- documentation for reset password [`#166`](https://github.com/gradido/gradido/pull/166)
+- 90 show release version in frontend [`#153`](https://github.com/gradido/gradido/pull/153)
+- docu frontend menu page structur [`#159`](https://github.com/gradido/gradido/pull/159)
+- userstorry_button.txt example [`#157`](https://github.com/gradido/gradido/pull/157)
+- fix getBalance API call [`#147`](https://github.com/gradido/gradido/pull/147)
+- Locale clear list merge master [`#119`](https://github.com/gradido/gradido/pull/119)
+- fix-125-link-to-community [`#152`](https://github.com/gradido/gradido/pull/152)
+- feat: Test Dashboard Layout [`#154`](https://github.com/gradido/gradido/pull/154)
+- feat: Activate Coverage Report For Unit Tests In Frontend [`#156`](https://github.com/gradido/gradido/pull/156)
+- Docu [`#120`](https://github.com/gradido/gradido/pull/120)
+- Fix compose bug [`#138`](https://github.com/gradido/gradido/pull/138)
+- feat: Test Login Form [`#113`](https://github.com/gradido/gradido/pull/113)
+- at last, fix email-bug [`#134`](https://github.com/gradido/gradido/pull/134)
+- Api password reset [`#82`](https://github.com/gradido/gradido/pull/82)
+- Optimize login server build [`#101`](https://github.com/gradido/gradido/pull/101)
+- markdown of login server api [`#111`](https://github.com/gradido/gradido/pull/111)
+- Fix lineendings [`#112`](https://github.com/gradido/gradido/pull/112)
+- Background color change [`#117`](https://github.com/gradido/gradido/pull/117)
+- Delete unused files [`#116`](https://github.com/gradido/gradido/pull/116)
+- store aufräumen teil 1 [`#115`](https://github.com/gradido/gradido/pull/115)
+- add migrations table for automatic table data migration [`40a9a8c`](https://github.com/gradido/gradido/commit/40a9a8c2b587f5bef0fcc54136ed7bd13dd91b2b)
+- update yarn.lock after running yarn install [`7f38c80`](https://github.com/gradido/gradido/commit/7f38c801213ad886e9d34a8d43b00ae423f5f2a0)
+- use new function for balance overview in old frontend, update balance in session on every php-request [`97c570c`](https://github.com/gradido/gradido/commit/97c570c08cc51ed17a69eb8be8d987f95f3c2ce0)
+
#### [0.9.4](https://github.com/gradido/gradido/compare/0.9.3...0.9.4)
+> 30 March 2021
+
+- Vue with nginx [`#84`](https://github.com/gradido/gradido/pull/84)
- Build on run [`#103`](https://github.com/gradido/gradido/pull/103)
- update debug docker to use dependencies container pushed to docker hub [`1f002f4`](https://github.com/gradido/gradido/commit/1f002f4ed0b12d4b2bf63efceabe546d0c5b58ea)
- removed email tasks complete [`8a143be`](https://github.com/gradido/gradido/commit/8a143be8423d7bd894d4f512848895df8b9694b0)
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/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');
diff --git a/community_server/db/skeema/gradido_community/migrations.sql b/community_server/db/skeema/gradido_community/migrations.sql
new file mode 100644
index 000000000..7665bcf29
--- /dev/null
+++ b/community_server/db/skeema/gradido_community/migrations.sql
@@ -0,0 +1,5 @@
+CREATE TABLE `migrations` (
+ `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
+ `db_version` int DEFAULT 0,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
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 1cdcf4418..a1416678f 100644
--- a/community_server/src/Controller/AppController.php
+++ b/community_server/src/Controller/AppController.php
@@ -21,7 +21,7 @@ use Cake\Routing\Router;
use Cake\ORM\TableRegistry;
use Cake\Core\Configure;
use Cake\I18n\Time;
-use Cake\I18n\I18n;
+use Cake\I18n\FrozenTime;
/**
* Application Controller
@@ -156,8 +156,25 @@ 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' => $html, 'db_version' => $current_db_version]);
+ }
+ }
+
+
protected function requestLogin($sessionId = 0, $redirect = true)
{
+ $this->checkForMigration($redirect);
+ $stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
$session = $this->getRequest()->getSession();
// check login
// disable encryption for cookies
@@ -190,12 +207,15 @@ class AppController extends Controller
$transactionPendings = $session->read('Transactions.pending');
$transactionExecutings = $session->read('Transactions.executing');
$transaction_can_signed = $session->read('Transactions.can_signed');
+
+
if ($session->read('session_id') != $session_id ||
( $userStored && (!isset($userStored['id']) || !$userStored['email_checked'])) ||
intval($transactionPendings) > 0 ||
intval($transactionExecutings) > 0 ||
- intval($transaction_can_signed > 0)) {
+ intval($transaction_can_signed > 0))
+ {
$http = new Client();
try {
@@ -226,6 +246,7 @@ class AppController extends Controller
$session->write('Transactions.can_signed', $transaction_can_signed);
$session->write('session_id', $session_id);
$stateUserTable = TableRegistry::getTableLocator()->get('StateUsers');
+
if (isset($json['user']['public_hex']) && $json['user']['public_hex'] != '') {
$public_key_bin = hex2bin($json['user']['public_hex']);
@@ -254,11 +275,6 @@ class AppController extends Controller
$this->Flash->error(__('error updating state user ' . json_encode($stateUser->errors())));
}
}
- //var_dump($stateUser);
- if (count($stateUser->state_balances) > 0) {
-
- $session->write('StateUser.balance', $stateUser->state_balances[0]->decay);
- }
$session->write('StateUser.id', $stateUser->id);
//echo $stateUser['id'];
} else {
@@ -310,6 +326,11 @@ class AppController extends Controller
//continue;
}
}
+ $state_balance = $stateBalancesTable->find()->where(['state_user_id' => $session->read('StateUser.id')])->first();
+ if ($state_balance) {
+ $now = new FrozenTime;
+ $session->write('StateUser.balance', $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now));
+ }
} else {
// no login
//die("no login");
diff --git a/community_server/src/Controller/AppRequestsController.php b/community_server/src/Controller/AppRequestsController.php
index 1993e3559..4d70a68b1 100644
--- a/community_server/src/Controller/AppRequestsController.php
+++ b/community_server/src/Controller/AppRequestsController.php
@@ -156,6 +156,9 @@ class AppRequestsController extends AppController
if($required_fields !== true) {
return $this->returnJson($required_fields);
}
+ if(!isset($params['memo']) || strlen($params['memo']) < 5 || strlen($params['memo']) > 150) {
+ return $this->returnJson(['state' => 'error', 'msg' => 'memo is not set or not in expected range [5;150]']);
+ }
$params['transaction_type'] = 'transfer';
$requestAnswear = $this->JsonRequestClient->sendRequest(json_encode($params), '/createTransaction');
@@ -323,23 +326,33 @@ class AppRequestsController extends AppController
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id'] ? $user['id'] : 0);
}
+ $stateUserTransactions_total = $stateUserTransactionsTable
+ ->find()
+ ->select(['id'])
+ ->where(['state_user_id' => $user['id']])
+ ->contain([]);
$stateUserTransactionsQuery = $stateUserTransactionsTable
->find()
->where(['state_user_id' => $user['id']])
- ->order(['balance_date' => 'ASC'])
+ ->order(['balance_date' => $orderDirection])
->contain([])
->limit($count)
->page($page)
;
$decay = true;
$transactions = [];
+ $transactions_from_db = $stateUserTransactionsQuery->toArray();
if($stateUserTransactionsQuery->count() > 0) {
- $transactions = $transactionsTable->listTransactionsHumanReadable($stateUserTransactionsQuery->toArray(), $user, $decay);
-
+ if($orderDirection == 'DESC') {
+ $transactions_from_db = array_reverse($transactions_from_db);
+ }
+ $transactions = $transactionsTable->listTransactionsHumanReadable($transactions_from_db, $user, $decay);
+
if($orderDirection == 'DESC') {
$transactions = array_reverse($transactions);
}
+
}
$state_balance = $stateBalancesTable->find()->where(['state_user_id' => $user['id']])->first();
@@ -348,7 +361,7 @@ class AppRequestsController extends AppController
'state' => 'success',
'transactions' => $transactions,
'transactionExecutingCount' => $session->read('Transactions.executing'),
- 'count' => count($transactions),
+ 'count' => $stateUserTransactions_total->count(),
'gdtSum' => $gdtSum,
'timeUsed' => microtime(true) - $startTime
];
@@ -360,7 +373,7 @@ class AppRequestsController extends AppController
$body['decay'] = 0.0;
} else {
$body['balance'] = $state_balance->amount;
- $body['decay'] = $state_balance->partDecay($now);
+ $body['decay'] = $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now);
}
$this->set('body', $body);
diff --git a/community_server/src/Controller/JsonRequestHandlerController.php b/community_server/src/Controller/JsonRequestHandlerController.php
index ba68f2b5a..12e03be8d 100644
--- a/community_server/src/Controller/JsonRequestHandlerController.php
+++ b/community_server/src/Controller/JsonRequestHandlerController.php
@@ -4,9 +4,9 @@ namespace App\Controller;
use App\Controller\AppController;
use Cake\ORM\TableRegistry;
-use Cake\Routing\Router;
use Cake\Http\Client;
use Cake\Core\Configure;
+use Cake\Mailer\Email;
use Model\Transactions\TransactionTransfer;
use Model\Transactions\Transaction;
@@ -332,33 +332,72 @@ class JsonRequestHandlerController extends AppController {
}
return $this->returnJson(['state' => 'success']);
}
+
+ private function sendEMailTransactionFailed($transaction, $reason_type)
+ {
+ $disable_email = Configure::read('disableEmail', false);
+ if($disable_email) {
+ return;
+ }
+ $transaction_body = $transaction->getTransactionBody();
+ $transaction_type_name = $transaction_body->getTransactionTypeName();
+ $senderUser = null;
+ if($transaction_type_name === 'transfer') {
+ $senderUser = $transaction_body->getSpecificTransaction()->getSenderUser();
+ } else if($transaction_type_name === 'creation') {
+ $senderUser = $transaction->getFirstSigningUser();
+ }
+ // send notification email
+ $noReplyEmail = Configure::read('noReplyEmail');
+ if($senderUser) {
+ try {
+ $email = new Email();
+ $emailViewBuilder = $email->viewBuilder();
+ $emailViewBuilder->setTemplate('notificationTransactionFailed')
+ ->setVars(['user' => $senderUser, 'transaction' => $transaction, 'reason' => $reason_type]);
+ $receiverNames = $senderUser->getNames();
+ if($receiverNames == '' || $senderUser->email == '') {
+ $this->addError('TransactionCreation::sendNotificationEmail', 'to email is empty for user: ' . $senderUser->id);
+ return false;
+ }
+ $email->setFrom([$noReplyEmail => 'Gradido (nicht antworten)'])
+ ->setTo([$senderUser->email => $senderUser->getNames()])
+ ->setSubject(__('Gradido Transaktion fehlgeschlagen!'))
+ ->send();
+ } catch(Exception $e) {
+ $this->addAdminError('JsonRequestController', 'sendEMailTransactionFailed', [$e->getMessage(), $reason_type], $senderUser->id);
+
+ }
+ }
+ }
private function putTransaction($transactionBase64) {
$transaction = new Transaction($transactionBase64);
//echo "after new transaction ";
if($transaction->hasErrors()) {
+ $this->sendEMailTransactionFailed($transaction, 'parse');
return $this->returnJson(['state' => 'error', 'msg' => 'error parsing transaction', 'details' => $transaction->getErrors()]);
}
//echo "after check on errors ";
if(!$transaction->validate()) {
+ //$transaction_details
+ $this->sendEMailTransactionFailed($transaction, 'validate');
return $this->returnJsonSaveError($transaction, ['state' => 'error', 'msg' => 'error validate transaction', 'details' => $transaction->getErrors()]);
}
//echo "after validate ";
if ($transaction->save()) {
-
-
// success
return $this->returnJson(['state' => 'success']);
} else {
+
+ $this->sendEMailTransactionFailed($transaction, 'save');
return $this->returnJsonSaveError($transaction, [
'state' => 'error',
'msg' => 'error saving transaction in db',
'details' => json_encode($transaction->getErrors())
]);
}
-
- return $this->returnJson(['state' => 'success']);
}
private function moveTransaction($pubkeys, $memo, $session_id) {
diff --git a/community_server/src/Controller/MigrationsController.php b/community_server/src/Controller/MigrationsController.php
new file mode 100644
index 000000000..97481aff5
--- /dev/null
+++ b/community_server/src/Controller/MigrationsController.php
@@ -0,0 +1,168 @@
+Auth->allow('migrate');
+ }
+
+ /**
+ * Index method
+ *
+ * @return \Cake\Http\Response|null
+ */
+ public function index()
+ {
+ $migrations = $this->paginate($this->Migrations);
+
+ $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 = $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');
+ $transactionTypesTable = TableRegistry::getTableLocator()->get('TransactionTypes');
+ $stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
+ $blockchainTypesTable = TableRegistry::getTableLocator()->get('BlockchainTypes');
+
+ $new_db_version = 1;
+
+ $commands = [];
+ // migrate from version 1 to 2
+ if($current_db_version == 1) {
+ $stateUserTransactionsTable->truncate();
+ $commands = [
+ [$blockchainTypesTable, 'fillWithDefault'],
+ [$transactionTypesTable, 'fillWithDefault'],
+ [$stateBalancesTable, 'truncate'],
+ [$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
+ *
+ * @param string|null $id Migration id.
+ * @return \Cake\Http\Response|null
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
+ */
+ public function view($id = null)
+ {
+ $migration = $this->Migrations->get($id, [
+ 'contain' => [],
+ ]);
+
+ $this->set('migration', $migration);
+ }
+
+ /**
+ * Add method
+ *
+ * @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
+ */
+ public function add()
+ {
+ $migration = $this->Migrations->newEntity();
+ if ($this->request->is('post')) {
+ $migration = $this->Migrations->patchEntity($migration, $this->request->getData());
+ if ($this->Migrations->save($migration)) {
+ $this->Flash->success(__('The migration has been saved.'));
+
+ return $this->redirect(['action' => 'index']);
+ }
+ $this->Flash->error(__('The migration could not be saved. Please, try again.'));
+ }
+ $this->set(compact('migration'));
+ }
+
+ /**
+ * Edit method
+ *
+ * @param string|null $id Migration id.
+ * @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
+ */
+ public function edit($id = null)
+ {
+ $migration = $this->Migrations->get($id, [
+ 'contain' => [],
+ ]);
+ if ($this->request->is(['patch', 'post', 'put'])) {
+ $migration = $this->Migrations->patchEntity($migration, $this->request->getData());
+ if ($this->Migrations->save($migration)) {
+ $this->Flash->success(__('The migration has been saved.'));
+
+ return $this->redirect(['action' => 'index']);
+ }
+ $this->Flash->error(__('The migration could not be saved. Please, try again.'));
+ }
+ $this->set(compact('migration'));
+ }
+
+ /**
+ * Delete method
+ *
+ * @param string|null $id Migration id.
+ * @return \Cake\Http\Response|null Redirects to index.
+ * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
+ */
+ public function delete($id = null)
+ {
+ $this->request->allowMethod(['post', 'delete']);
+ $migration = $this->Migrations->get($id);
+ if ($this->Migrations->delete($migration)) {
+ $this->Flash->success(__('The migration has been deleted.'));
+ } else {
+ $this->Flash->error(__('The migration could not be deleted. Please, try again.'));
+ }
+
+ return $this->redirect(['action' => 'index']);
+ }
+}
diff --git a/community_server/src/Controller/StateBalancesController.php b/community_server/src/Controller/StateBalancesController.php
index 3994b989a..0dc9b672d 100644
--- a/community_server/src/Controller/StateBalancesController.php
+++ b/community_server/src/Controller/StateBalancesController.php
@@ -2,7 +2,7 @@
namespace App\Controller;
use Cake\ORM\TableRegistry;
-use Cake\I18n\Time;
+use Cake\I18n\FrozenTime;
use Model\Navigation\NaviHierarchy;
use Model\Navigation\NaviHierarchyEntry;
@@ -62,9 +62,10 @@ 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
// listPerEmailApi
@@ -84,200 +85,68 @@ class StateBalancesController extends AppController
//}
//
//
+ $stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
-
- $creationsTable = TableRegistry::getTableLocator()->get('TransactionCreations');
- $creationTransactions = $creationsTable
- ->find('all')
- ->where(['state_user_id' => $user['id']])
- ->contain(['Transactions']);
-
- $transferTable = TableRegistry::getTableLocator()->get('TransactionSendCoins');
- $transferTransactions = $transferTable
- ->find('all')
- ->where(['OR' => ['state_user_id' => $user['id'], 'receiver_user_id' => $user['id']]])
- ->contain(['Transactions']);
-
- $involvedUserIds = [];
-
- foreach ($transferTransactions as $sendCoins) {
- //var_dump($sendCoins);
- if ($sendCoins->state_user_id != $user['id']) {
- array_push($involvedUserIds, intval($sendCoins->state_user_id));
- } elseif ($sendCoins->receiver_user_id != $user['id']) {
- array_push($involvedUserIds, intval($sendCoins->receiver_user_id));
- }
- }
-
- /*echo "state user from sendCoins: $sendCoins->state_user_id ";
- echo "receiver user from sendCoins: $sendCoins->receiver_user_id ";
- echo "user id from logged in user: ".$user['id']. ' ';
- */
- //var_dump($involvedUserIds);
- // exchange key with values and drop duplicates
- $involvedUser_temp = array_flip($involvedUserIds);
- // exchange back
- $involvedUserIds = array_flip($involvedUser_temp);
- $userTable = TableRegistry::getTableLocator()->get('StateUsers');
- $involvedUser = $userTable->find('all', [
- 'contain' => false,
- 'where' => ['id IN' => $involvedUserIds],
- 'fields' => ['id', 'first_name', 'last_name', 'email']
- ]);
- //var_dump($involvedUser->toArray());
- $involvedUserIndices = [];
- foreach ($involvedUser as $involvedUser) {
- $involvedUserIndices[$involvedUser->id] = $involvedUser;
- }
-
- // sender or receiver when user has sended money
- // group name if creation
- // type: gesendet / empfangen / geschöpft
- // transaktion nr / id
- // date
- // balance
-
- $transactions = [];
- foreach ($creationTransactions as $creation) {
- //var_dump($creation);
- array_push($transactions, [
- 'name' => 'Gradido Akademie',
- 'type' => 'creation',
- 'transaction_id' => $creation->transaction_id,
- 'date' => $creation->target_date,
- 'balance' => $creation->amount,
- 'memo' => $creation->transaction->memo
- ]);
- }
-
- foreach ($transferTransactions as $sendCoins) {
- $type = '';
- $otherUser = null;
- $other_user_public = '';
- if ($sendCoins->state_user_id == $user['id']) {
- $type = 'send';
-
- if(isset($involvedUserIndices[$sendCoins->receiver_user_id])) {
- $otherUser = $involvedUserIndices[$sendCoins->receiver_user_id];
- }
- $other_user_public = bin2hex(stream_get_contents($sendCoins->receiver_public_key));
- } else if ($sendCoins->receiver_user_id == $user['id']) {
- $type = 'receive';
- if(isset($involvedUserIndices[$sendCoins->state_user_id])) {
- $otherUser = $involvedUserIndices[$sendCoins->state_user_id];
- }
- if($sendCoins->sender_public_key) {
- $other_user_public = bin2hex(stream_get_contents($sendCoins->sender_public_key));
- }
- }
- if(null == $otherUser) {
- $otherUser = $this->StateBalances->StateUsers->newEntity();
- }
- array_push($transactions, [
- 'name' => $otherUser->first_name . ' ' . $otherUser->last_name,
- 'email' => $otherUser->email,
- 'type' => $type,
- 'transaction_id' => $sendCoins->transaction_id,
- 'date' => $sendCoins->transaction->received,
- 'balance' => $sendCoins->amount,
- 'memo' => $sendCoins->transaction->memo,
- 'pubkey' => $other_user_public
- ]);
- }
- uasort($transactions, array($this, 'sortTransactions'));
+ $transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
- // add decay transactions
- $month_start_state_balance = null;
- $current_state_balance = null;
- $cursor = 0;
- $transactions_reversed = array_reverse($transactions);
- $decay_transactions = [];
- $maxI = count($transactions_reversed);
+
+ $stateBalancesTable->updateBalances($user['id']);
- foreach($transactions_reversed as $i => $transaction) {
- if(!isset($transaction['transaction_id'])) {
- //echo "missing transaction ";
- continue;
- }
- $transaction_id = $transaction['transaction_id'];
- //echo "transaction id: $transaction_id ";
- $decay_transaction = NULL;
- $state_balance = $this->StateBalances->newEntity();
-
- if($i > 0 && isset($transactions_reversed[$i-1]['transaction_id'])) {
- $prev_transaction = $transactions_reversed[$i-1];
- $stateUserTransactions = $stateUserTransactionsTable
- ->find()
- ->where([
- 'transaction_id IN' => [$transaction_id, $prev_transaction['transaction_id']],
- 'state_user_id' => $user['id']
- ])
- ->order(['balance_date ASC'])
- ->toArray();
-
- $prev = $stateUserTransactions[0];
- if($prev->balance > 0) {
- // var_dump($stateUserTransactions);
- $current = $stateUserTransactions[1];
- //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);
-
- //echo $interval->format('%R%a days');
- //echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . " ";
- $decay_transaction = [
- 'type' => 'decay',
- 'balance' => -intval($prev->balance - $diff_amount),
- 'decay_duration' => $interval->format('%a days, %H hours, %I minutes, %S seconds'),
- 'memo' => ''
- ];
- }
- }
-
- if($decay_transaction) {
- $decay_transactions[] = $decay_transaction;
- //array_splice($transactions_reversed, $i + $cursor, 0, [$decay_transaction]);
- //$cursor++;
- }
- if($i == $maxI-1) {
- $stateUserTransaction = $stateUserTransactionsTable
- ->find()
- ->where(['transaction_id' => $transaction_id, 'state_user_id' => $user['id']])
- ->order(['transaction_id ASC'])->first();
- //var_dump($stateUserTransaction);
- $state_balance->amount = $stateUserTransaction->balance;
- $state_balance->record_date = $stateUserTransaction->balance_date;
- $decay_transactions[] = [
- //$transactions_reversed[] = [
- 'type' => 'decay',
- 'balance' => -intval($stateUserTransaction->balance - $state_balance->decay),
- 'decay_duration' => $stateUserTransaction->balance_date->timeAgoInWords(),
- 'memo' => ''
- ];
-
- }
+ $gdtSum = 0;
+ $gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
+
+ if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
+ $gdtSum = intval($gdtEntries['data']['sum']);
+ } else {
+ $this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id'] ? $user['id'] : 0);
}
- $final_transactions = [];
- foreach($transactions_reversed as $i => $transaction) {
- $final_transactions[] = $transaction;
- $final_transactions[] = $decay_transactions[$i];
+
+
+ $stateUserTransactionsQuery = $stateUserTransactionsTable
+ ->find()
+ ->where(['state_user_id' => $user['id']])
+ ->order(['balance_date' => 'ASC'])
+ ->contain([])
+ ;
+ $decay = true;
+ $transactions = [];
+ if($stateUserTransactionsQuery->count() > 0) {
+ $transactions = $transactionsTable->listTransactionsHumanReadable($stateUserTransactionsQuery->toArray(), $user, $decay);
+ }
+
+ $state_balance = $stateBalancesTable->find()->where(['state_user_id' => $user['id']])->first();
+
+ $body = [
+ 'state' => 'success',
+ 'transactions' => $transactions,
+ 'transactionExecutingCount' => $session->read('Transactions.executing'),
+ 'count' => count($transactions),
+ 'gdtSum' => $gdtSum,
+ 'timeUsed' => microtime(true) - $startTime
+ ];
+ $now = new FrozenTime();
+ $body['decay_date'] = $now;
+
+ if(!$state_balance) {
+ $balance = 0.0;
+ } else {
+ $balance = $stateBalancesTable->calculateDecay($state_balance->amount, $state_balance->record_date, $now);
+ //$balance = $state_balance->partDecay($now);
}
- // for debugging
$calculated_balance = 0;
- foreach($final_transactions as $tr) {
- if($tr['type'] == 'send') {
- $calculated_balance -= intval($tr['balance']);
+ foreach($transactions as $transaction) {
+ if($transaction['type'] == 'decay' || $transaction['type'] == 'send') {
+ $calculated_balance -= $transaction['balance'];
} else {
- $calculated_balance += intval($tr['balance']);
+ $calculated_balance += $transaction['balance'];
}
}
+
$this->set('calculated_balance', $calculated_balance);
- $this->set('transactions', array_reverse($final_transactions));
+ $this->set('transactions', array_reverse($transactions));
$this->set('transactionExecutingCount', $session->read('Transactions.executing'));
- $this->set('balance', $session->read('StateUser.balance'));
+ $this->set('balance', $balance);
$this->set('timeUsed', microtime(true) - $startTime);
$this->set('gdtSum', $gdtSum);
}
@@ -301,151 +170,16 @@ class StateBalancesController extends AppController
if(!$state_balance) {
return $this->returnJson(['state' => 'success', 'balance' => 0]);
}
+ $now = new FrozenTime();
return $this->returnJson([
'state' => 'success',
'balance' => $state_balance->amount,
- 'decay' => $state_balance->decay
+ 'decay' => $this->StateBalances->calculateDecay($state_balance->amount, $state_balance->record_date, $now),
+ 'decay_date' => $now
]);
}
-
- public function ajaxListTransactions($session_id, $page=1, $count=25)
- {
- if(!$session_id) {
- return $this->returnJson(['state' => 'error', 'msg' => 'invalid session id']);
- }
-
- $startTime = microtime(true);
- $login_result = $this->requestLogin($session_id, false);
- if($login_result !== true) {
- return $this->returnJson($login_result);
- }
- $session = $this->getRequest()->getSession();
- $user = $session->read('StateUser');
-
- $this->StateBalances->updateBalances($user['id']);
-
- $gdtSum = 0;
- $gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
-
- if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
- $gdtSum = intval($gdtEntries['data']['sum']);
- } else {
- if($user) {
- $this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id']);
- } else {
- $this->addAdminError('StateBalancesController', 'overview', $gdtEntries, 0);
- }
- }
-
- $creationsTable = TableRegistry::getTableLocator()->get('TransactionCreations');
- $creationTransactions = $creationsTable
- ->find('all')
- ->where(['state_user_id' => $user['id']])
- ->contain(['Transactions']);
-
- $transferTable = TableRegistry::getTableLocator()->get('TransactionSendCoins');
- $transferTransactions = $transferTable
- ->find('all')
- ->where(['OR' => ['state_user_id' => $user['id'], 'receiver_user_id' => $user['id']]])
- ->contain(['Transactions']);
-
- $involvedUserIds = [];
-
- foreach ($transferTransactions as $sendCoins) {
- //var_dump($sendCoins);
- if ($sendCoins->state_user_id != $user['id']) {
- array_push($involvedUserIds, intval($sendCoins->state_user_id));
- } elseif ($sendCoins->receiver_user_id != $user['id']) {
- array_push($involvedUserIds, intval($sendCoins->receiver_user_id));
- }
- }
-
- /*echo "state user from sendCoins: $sendCoins->state_user_id ";
- echo "receiver user from sendCoins: $sendCoins->receiver_user_id ";
- echo "user id from logged in user: ".$user['id']. ' ';
- */
- //var_dump($involvedUserIds);
- // exchange key with values and drop duplicates
- $involvedUser_temp = array_flip($involvedUserIds);
- // exchange back
- $involvedUserIds = array_flip($involvedUser_temp);
- $userTable = TableRegistry::getTableLocator()->get('StateUsers');
- $involvedUser = $userTable->find('all', [
- 'contain' => false,
- 'where' => ['id IN' => $involvedUserIds],
- 'fields' => ['id', 'first_name', 'last_name', 'email']
- ]);
- //var_dump($involvedUser->toArray());
- $involvedUserIndices = [];
- foreach ($involvedUser as $involvedUser) {
- $involvedUserIndices[$involvedUser->id] = $involvedUser;
- }
-
- // sender or receiver when user has sended money
- // group name if creation
- // type: gesendet / empfangen / geschöpft
- // transaktion nr / id
- // date
- // balance
-
- $transactions = [];
- foreach ($creationTransactions as $creation) {
- //var_dump($creation);
- array_push($transactions, [
- 'name' => 'Gradido Akademie',
- 'type' => 'creation',
- 'transaction_id' => $creation->transaction_id,
- 'date' => $creation->transaction->received,
- 'balance' => $creation->amount,
- 'memo' => $creation->transaction->memo
- ]);
- }
-
- foreach ($transferTransactions as $sendCoins) {
- $type = '';
- $otherUser = null;
- if ($sendCoins->state_user_id == $user['id']) {
- $type = 'send';
-
- if(isset($involvedUserIndices[$sendCoins->receiver_user_id])) {
- $otherUser = $involvedUserIndices[$sendCoins->receiver_user_id];
- }
- } else if ($sendCoins->receiver_user_id == $user['id']) {
- $type = 'receive';
- if(isset($involvedUserIndices[$sendCoins->state_user_id])) {
- $otherUser = $involvedUserIndices[$sendCoins->state_user_id];
- }
- }
- if(null == $otherUser) {
- $otherUser = $this->StateBalances->StateUsers->newEntity();
- }
- array_push($transactions, [
- 'name' => $otherUser->first_name . ' ' . $otherUser->last_name,
- 'email' => $otherUser->email,
- 'type' => $type,
- 'transaction_id' => $sendCoins->transaction_id,
- 'date' => $sendCoins->transaction->received,
- 'balance' => $sendCoins->amount,
- 'memo' => $sendCoins->transaction->memo
- ]);
- }
- uasort($transactions, array($this, 'sortTransactions'));
- if($sort == 'DESC') {
- $transactions = array_reverse($transactions);
- }
- return $this->returnJson([
- 'state' => 'success',
- 'transactions' => $transactions,
- 'transactionExecutingCount' => $session->read('Transactions.executing'),
- 'count' => count($transactions),
- 'gdtSum' => $gdtSum,
- 'timeUsed' => microtime(true) - $startTime
- ]);
- }
-
-
public function ajaxGdtOverview()
{
diff --git a/community_server/src/Controller/TransactionSendCoinsController.php b/community_server/src/Controller/TransactionSendCoinsController.php
index 033e2343f..1018309cc 100644
--- a/community_server/src/Controller/TransactionSendCoinsController.php
+++ b/community_server/src/Controller/TransactionSendCoinsController.php
@@ -237,6 +237,11 @@ class TransactionSendCoinsController extends AppController
$this->set('timeUsed', microtime(true) - $startTime);
return;
}
+ if($answear_data['msg'] === 'memo is not set or not in expected range [5;150]') {
+ $this->Flash->error(__('Ein Verwendungszweck zwischen 5 und 150 Zeichen wird benötig!'));
+ $this->set('timeUsed', microtime(true) - $startTime);
+ return;
+ }
} else if($answear_data['state'] === 'not found' && $answear_data['msg'] === 'receiver not found') {
$this->Flash->error(__('Der Empfänger wurde nicht auf dem Login-Server gefunden, hat er sein Konto schon angelegt?'));
$this->set('timeUsed', microtime(true) - $startTime);
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/Entity/Migration.php b/community_server/src/Model/Entity/Migration.php
new file mode 100644
index 000000000..700136cf8
--- /dev/null
+++ b/community_server/src/Model/Entity/Migration.php
@@ -0,0 +1,26 @@
+ true,
+ ];
+}
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
new file mode 100644
index 000000000..a0758c97a
--- /dev/null
+++ b/community_server/src/Model/Table/AppTable.php
@@ -0,0 +1,41 @@
+getSchema()->truncateSql($this->getConnection());
+ foreach ($truncateCommands as $truncateCommand) {
+ $this->getConnection()->query($truncateCommand);
+ }
+ $this->getConnection()->query('ALTER TABLE ' . $this->getSchema()->name() . ' AUTO_INCREMENT=1');
+ return ['success' => true];
+ }
+ 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 90213ac9f..3aa67a83d 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,30 @@ 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->saveManyWithErrors($entities);
+ if(!$save_results['success']) {
+ $save_results['msg'] = 'error by saving default transaction types';
+ }
+ return $save_results;
+
+ }
}
diff --git a/community_server/src/Model/Table/MigrationsTable.php b/community_server/src/Model/Table/MigrationsTable.php
new file mode 100644
index 000000000..b5cb42154
--- /dev/null
+++ b/community_server/src/Model/Table/MigrationsTable.php
@@ -0,0 +1,56 @@
+setTable('migrations');
+ $this->setDisplayField('id');
+ $this->setPrimaryKey('id');
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->nonNegativeInteger('id')
+ ->allowEmptyString('id', null, 'create');
+
+ $validator
+ ->integer('db_version')
+ ->allowEmptyString('db_version');
+
+ return $validator;
+ }
+}
diff --git a/community_server/src/Model/Table/StateBalancesTable.php b/community_server/src/Model/Table/StateBalancesTable.php
index 7564c30f2..25d588f30 100644
--- a/community_server/src/Model/Table/StateBalancesTable.php
+++ b/community_server/src/Model/Table/StateBalancesTable.php
@@ -1,14 +1,12 @@
'INNER'
]);
}
+
+ public static function getDecayStartDateCached()
+ {
+ if(self::$startDecayDate == null) {
+ $transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
+ self::$startDecayDate = $transactionsTable->getDecayStartDate();
+ }
+ return self::$startDecayDate;
+ }
/**
* Default validation rules.
@@ -83,20 +91,60 @@ class StateBalancesTable extends Table
return $rules;
}
-
- public function sortTransactions($a, $b)
+ public function calculateDecay($startBalance, FrozenTime $startDate, FrozenTime $endDate, $withInterval = false)
{
- if ($a['date'] == $b['date']) {
- return 0;
+ $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) {
+ if($withInterval) {
+ return ['balance' => $startBalance, 'interval' => new \DateInterval('PT0S')];
+ } else {
+ return $startBalance;
+ }
}
- return ($a['date'] > $b['date']) ? -1 : 1;
+ $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);
+ }
+ $decay = $state_balance->partDecay($endDate);
+ if($withInterval) {
+ return ['balance' => $decay, 'interval' => $interval];
+ } else {
+ return $decay;
+ }
+
+
}
+ 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');
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
+ $now = new FrozenTime;
// info: cakephp use lazy loading, query will be executed later only if needed
$state_balances = $this->find('all')->where(['state_user_id' => $stateUserId]);
$state_user_transactions = $stateUserTransactionsTable
@@ -107,7 +155,7 @@ class StateBalancesTable extends Table
;
if(!$state_user_transactions || !$state_user_transactions->count()) {
- return true;
+ return ['success' => true];
}
// first: decide what todo
@@ -128,18 +176,26 @@ class StateBalancesTable extends Table
if($state_user_transactions->count() == 0){
$clear_state_balance = true;
} else {
+
+ $first_state_balance = $state_balances->first();
+ $first_state_balance_decayed = self::calculateDecay(
+ $first_state_balance->amount,
+ $first_state_balance->record_date,
+ $now);
+
$last_state_user_transaction = $state_user_transactions->last();
- $last_transaction = $this->newEntity();
- $last_transaction->amount = $last_state_user_transaction->balance;
- $last_transaction->record_date = $last_state_user_transaction->balance_date;
+ $last_state_user_transaction_decayed = self::calculateDecay(
+ $last_state_user_transaction->balance,
+ $last_state_user_transaction->balance_date,
+ $now);
// if entrys are nearly the same, we don't need doing anything
- if(abs($last_transaction->decay - $state_balances->first()->decay) > 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;
}
}
}
-
+
if(!$recalculate_state_user_transactions_balance) {
$last_state_user_transaction = $state_user_transactions->last();
if($last_state_user_transaction && $last_state_user_transaction->balance <= 0) {
@@ -193,37 +249,28 @@ 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 = $balance_cursor->partDecay($amount_date) + $amount;
+ $balance_cursor->amount =
+ $this->calculateDecay($balance_cursor->amount, $balance_cursor->record_date, $amount_date)
+ + $amount;
}
//echo "new balance: " . $balance_cursor->amount . " ";
@@ -261,7 +308,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/TransactionTypesTable.php b/community_server/src/Model/Table/TransactionTypesTable.php
index 5cc842f5e..2ffd1e64c 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
@@ -55,7 +55,7 @@ class TransactionTypesTable extends Table
$validator
->scalar('name')
- ->maxLength('name', 24)
+ ->maxLength('name', 45)
->requirePresence('name', 'create')
->notEmptyString('name');
@@ -66,4 +66,55 @@ 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->saveManyWithErrors($entities);
+ if(!$save_results['success']) {
+ $save_results['msg'] = 'error by saving default transaction types';
+ }
+ return $save_results;
+ }
}
diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php
index 2ff39f469..c4bc4b698 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);
- $balance = floatval($prev->balance - $diff_amount);
+ $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true);
+ $balance = floatval($prev->balance - $calculated_decay['balance']);
// skip small decays (smaller than 0,00 GDD)
if(abs($balance) >= 100) {
@@ -192,7 +193,7 @@ class TransactionsTable extends Table
$final_transactions[] = [
'type' => 'decay',
'balance' => $balance,
- 'decay_duration' => $interval->format('%a days, %H hours, %I minutes, %S seconds'),
+ 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'),
'memo' => ''
];
}
@@ -211,12 +212,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' => $creation->target_date,
- 'balance' => $creation->amount,
+ 'date' => $transaction->received,// $creation->target_date,
+ 'target_date' => $creation->target_date,
+ 'creation_amount' => $creation->amount,
+ 'balance' => $balance,
'memo' => $transaction->memo
];
} else if($su_transaction->transaction_type_id == 2) { // transfer or send coins
@@ -256,14 +261,21 @@ class TransactionsTable extends Table
}
if($i == $stateUserTransactionsCount-1 && $decay == true) {
- $state_balance->amount = $su_transaction->balance;
- $state_balance->record_date = $su_transaction->balance_date;
- $balance = floatval($su_transaction->balance - $state_balance->decay);
+ $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();
+ }
+ $balance = floatval($su_transaction->balance - $calculated_decay['balance']);
if($balance > 100) {
$final_transactions[] = [
'type' => 'decay',
'balance' => $balance,
- 'decay_duration' => $su_transaction->balance_date->timeAgoInWords(),
+ 'decay_duration' => $duration,
+ 'last_decay' => true,
'memo' => ''
];
}
@@ -273,4 +285,169 @@ 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()];
+ }
+
+ /*!
+ * @return: false if no decay start block found
+ * @return: DateTime Object with start date if one start block found
+ * @return: ['state':'error'] if more than one found
+ */
+ public function getDecayStartDate()
+ {
+ $transaction = $this->find()->where(['transaction_type_id' => 9])->select(['received'])->order(['received' => 'ASC']);
+ if($transaction->count() == 0) {
+ return null;
+ }
+ return $transaction->first()->received;
+ }
+
+ 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
+ ->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;
+ }
+ }
+ }
+ }
+ if(count($state_user_ids) < 1) {
+ return ['success' => true];
+ }
+ //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);
+ }
+ }
+
+ $save_results = $this->StateUserTransactions->saveManyWithErrors($finalEntities);
+ if(!$save_results['success']) {
+ $save_results['msg'] = 'error by saving at least one state user transaction';
+ }
+ return $save_results;
+ }
}
diff --git a/community_server/src/Model/Transactions/Transaction.php b/community_server/src/Model/Transactions/Transaction.php
index 21beb1d31..40be13cd3 100644
--- a/community_server/src/Model/Transactions/Transaction.php
+++ b/community_server/src/Model/Transactions/Transaction.php
@@ -98,6 +98,11 @@ class Transaction extends TransactionBase {
return $sigPairs[0]->getPubKey();
}
+ public function getFirstSigningUser()
+ {
+ return $this->getStateUserFromPublickey($this->getFirstPublic());
+ }
+
public function getId() {
return $this->mProtoTransaction->getId();
}
diff --git a/community_server/src/Model/Transactions/TransactionBase.php b/community_server/src/Model/Transactions/TransactionBase.php
index a688daf02..607903d8d 100644
--- a/community_server/src/Model/Transactions/TransactionBase.php
+++ b/community_server/src/Model/Transactions/TransactionBase.php
@@ -60,6 +60,16 @@ class TransactionBase {
return NULL;
}
+
+ protected function getStateUserFromPublickey($publicKey) {
+ $stateUsersTable = self::getTable('state_users');
+ $stateUser = $stateUsersTable->find('all')->where(['public_key' => $publicKey])->first();
+ if($stateUser) {
+ return $stateUser;
+ }
+
+ return NULL;
+ }
protected function updateStateBalance($stateUserId, $addAmountCent, $recordDate) {
@@ -72,9 +82,11 @@ class TransactionBase {
//debug($stateBalanceQuery);
if($stateBalanceQuery->count() > 0) {
+
$stateBalanceEntry = $stateBalanceQuery->first();
- $stateBalanceEntry->amount = $stateBalanceEntry->partDecay($recordDate) + $addAmountCent;
- $stateBalanceEntry->amount += $addAmountCent;
+ $stateBalanceEntry->amount =
+ $stateBalancesTable->calculateDecay($stateBalanceEntry->amount, $stateBalanceEntry->record_date, $recordDate)
+ + $addAmountCent;
} else {
$stateBalanceEntry = $stateBalancesTable->newEntity();
$stateBalanceEntry->state_user_id = $stateUserId;
@@ -93,11 +105,12 @@ class TransactionBase {
protected function addStateUserTransaction($stateUserId, $transactionId, $transactionTypeId, $balance, $balance_date) {
$stateUserTransactionTable = self::getTable('state_user_transactions');
+
$stateUserTransactions = $stateUserTransactionTable
->find('all')
->where(['state_user_id' => $stateUserId])
->order(['transaction_id DESC']);
-
+ $new_balance = $balance;
if($stateUserTransactions->count() > 0) {
$stateBalanceTable = self::getTable('state_balances');
$state_user_transaction = $stateUserTransactions->first();
@@ -105,16 +118,17 @@ class TransactionBase {
$this->addError('TransactionBase::addStateUserTransaction', 'state_user_transaction is zero, no first entry exist?');
return false;
}
- $balance_entity = $stateBalanceTable->newEntity();
- $balance_entity->amount = $state_user_transaction->balance;
- $balance_entity->record_date = $state_user_transaction->balance_date;
- $balance = $balance_entity->decay + $balance;
+ $new_balance += $stateBalanceTable->calculateDecay(
+ $state_user_transaction->balance,
+ $state_user_transaction->balance_date,
+ $balance_date
+ );
}
$entity = $stateUserTransactionTable->newEntity();
$entity->state_user_id = $stateUserId;
$entity->transaction_id = $transactionId;
$entity->transaction_type_id = $transactionTypeId;
- $entity->balance = $balance;
+ $entity->balance = $new_balance;
$entity->balance_date = $balance_date;
if(!$stateUserTransactionTable->save($entity)) {
diff --git a/community_server/src/Model/Transactions/TransactionCreation.php b/community_server/src/Model/Transactions/TransactionCreation.php
index 6aeddd955..f9b3c7657 100644
--- a/community_server/src/Model/Transactions/TransactionCreation.php
+++ b/community_server/src/Model/Transactions/TransactionCreation.php
@@ -72,7 +72,12 @@ class TransactionCreation extends TransactionBase {
return $this->protoTransactionCreation->getReceiver()->getPubkey();
}
-
+ public function getReceiverUser() {
+ return $this->getStateUserFromPublickey($this->getReceiverPublic());
+ }
+ public function getTargetDate() {
+ return new FrozenDate($this->protoTransactionCreation->getTargetDate()->getSeconds());
+ }
public function validate($sigPairs) {
// check if receiver public is not in signature list
@@ -138,8 +143,9 @@ class TransactionCreation extends TransactionBase {
return true;
}
- public function save($transaction_id, $firstPublic)
+ public function save($transaction_id, $firstPublic, $received)
{
+ $stateBalancesTable = self::getTable('stateBalances');
$transactionCreationEntity = $this->transactionCreationsTable->newEntity();
$transactionCreationEntity->transaction_id = $transaction_id;
@@ -151,23 +157,27 @@ class TransactionCreation extends TransactionBase {
$this->addError('TransactionCreation::save', 'couldn\'t get state user id');
return false;
}
+
$transactionCreationEntity->state_user_id = $receiverUserId;
$transactionCreationEntity->amount = $this->getAmount();
$transactionCreationEntity->target_date = $this->protoTransactionCreation->getTargetDate()->getSeconds();
$target_date = new FrozenTime($transactionCreationEntity->target_date);
+
+ $decayed_balance = $stateBalancesTable->calculateDecay($this->getAmount(), $target_date, $received);
+
if(!$this->transactionCreationsTable->save($transactionCreationEntity)) {
$this->addError('TransactionCreation::save', 'error saving transactionCreation with errors: ' . json_encode($transactionCreationEntity->getErrors()));
return false;
}
// update state balance
- $final_balance = $this->updateStateBalance($receiverUserId, $this->getAmount(), $target_date);
+ $final_balance = $this->updateStateBalance($receiverUserId, $decayed_balance, $received);
if(false === $final_balance) {
return false;
}
// decay is a virtual field which is calculated from amount and now() - record_date
- if(!$this->addStateUserTransaction($receiverUserId, $transaction_id, 1, $this->getAmount(), $target_date)) {
+ if(!$this->addStateUserTransaction($receiverUserId, $transaction_id, 1, $decayed_balance, $received)) {
return false;
}
diff --git a/community_server/src/Model/Transactions/TransactionTransfer.php b/community_server/src/Model/Transactions/TransactionTransfer.php
index 3156e2cae..4f3f4e88c 100644
--- a/community_server/src/Model/Transactions/TransactionTransfer.php
+++ b/community_server/src/Model/Transactions/TransactionTransfer.php
@@ -186,11 +186,9 @@ class TransactionTransfer extends TransactionBase {
$local_transfer = $this->protoTransactionTransfer->getLocal();
$sender = $local_transfer->getSender();
$senderAmount = $sender->getAmount();
- $senderUserId = $this->getStateUserId($sender->getPubkey());
- $receiverUserId = $this->getStateUserId($local_transfer->getReceiver());
+ $senderUser = $this->getStateUserFromPublickey($sender->getPubkey());
+ $receiverUser = $this->getStateUserFromPublickey($local_transfer->getReceiver());
- $receiverUser = $this->getStateUser($receiverUserId);
- $senderUser = $this->getStateUser($senderUserId);
$serverAdminEmail = Configure::read('ServerAdminEmail');
try {
@@ -218,6 +216,25 @@ class TransactionTransfer extends TransactionBase {
return true;
}
+ public function getSenderUser()
+ {
+ $local_transfer = $this->protoTransactionTransfer->getLocal();
+ return $this->getStateUserFromPublickey($local_transfer->getSender()->getPubkey());
+ }
+
+ public function getReceiverUser()
+ {
+ $local_transfer = $this->protoTransactionTransfer->getLocal();
+ return $this->getStateUserFromPublickey($local_transfer->getReceiver());
+ }
+
+ public function getAmount()
+ {
+ $local_transfer = $this->protoTransactionTransfer->getLocal();
+ $sender = $local_transfer->getSender();
+ return $sender->getAmount();
+ }
+
static public function fromEntity($transactionTransferEntity)
{
$protoTransfer = new \Proto\Gradido\GradidoTransfer();
diff --git a/community_server/src/Template/AppRequests/list_transactions.ctp b/community_server/src/Template/AppRequests/list_transactions.ctp
index f829b5f16..d7a8b1d6f 100644
--- a/community_server/src/Template/AppRequests/list_transactions.ctp
+++ b/community_server/src/Template/AppRequests/list_transactions.ctp
@@ -11,7 +11,14 @@ $body['decay'] = $this->element('centToFloat', ['cent' => $body['decay'], 'preci
$body['gdtSum'] = $this->element('centToFloat', ['cent' => $body['gdtSum'], 'precision' => 2]);
foreach($body['transactions'] as $i => $transaction) {
- $body['transactions'][$i]['balance'] = $this->element('centToFloat', ['cent' => $transaction['balance'], 'precision' => 4]);
+ $useCeil = false;
+ if(isset($transaction['last_decay']) && $transaction['last_decay']) {
+ $useCeil = true;
+ }
+ $body['transactions'][$i]['balance'] = $this->element('centToFloat', ['cent' => $transaction['balance'], 'precision' => 4, 'useCeil' => $useCeil]);
+ if(isset($transaction['creation_amount'])) {
+ $body['transactions'][$i]['creation_amount'] = $this->element('centToFloat', ['cent' => $transaction['creation_amount'], 'precision' => 4]);
+ }
}
?>= json_encode($body) ?>
\ No newline at end of file
diff --git a/community_server/src/Template/Element/centToFloat.ctp b/community_server/src/Template/Element/centToFloat.ctp
index 2fade18b2..3beabf837 100644
--- a/community_server/src/Template/Element/centToFloat.ctp
+++ b/community_server/src/Template/Element/centToFloat.ctp
@@ -9,7 +9,11 @@
$cut_places = $precision - 2;
$transformAmount = $cent;
if($cut_places > 0) {
- $transformAmount = floor($cent / pow(10, $cut_places));
+ if(isset($useCeil) && $useCeil) {
+ $transformAmount = ceil($cent / pow(10, $cut_places));
+ } else {
+ $transformAmount = floor($cent / pow(10, $cut_places));
+ }
}
if($cut_places < 0) {
$cut_places = 0;
diff --git a/community_server/src/Template/Email/text/notification_transaction_failed.ctp b/community_server/src/Template/Email/text/notification_transaction_failed.ctp
new file mode 100644
index 000000000..975848e58
--- /dev/null
+++ b/community_server/src/Template/Email/text/notification_transaction_failed.ctp
@@ -0,0 +1,50 @@
+assign('title', __('Gradido Transaktion fehlgeschlagen'));
+
+$transaction_body = $transaction->getTransactionBody();
+$specific_transaction = $transaction_body->getSpecificTransaction();
+$transaction_type_name = $transaction_body->getTransactionTypeName();
+
+?>= __('Hallo') ?> = $user->first_name ?> = $user->last_name ?>,
+
+= __('Deine letzte Transaktion ist leider fehlgeschlagen.') ?>
+
+
+= __('Du wolltest {0} für {1} schöpfen.',
+ $this->element('printGradido', ['number' => $specific_transaction->getAmount(), 'raw' => true]),
+ $specific_transaction->getReceiverUser()->getEmailWithName()) ?>
+
+= __('Das Zieldatum war: ') . $specific_transaction->getTargetDate()->format('d.m.Y') ?>
+
+= __('Du wolltest {0} an {1} senden.',
+ $this->element('printGradido', ['number' => $specific_transaction->getAmount(), 'raw' => true]),
+ $specific_transaction->getReceiverUser()->getEmailWithName()) ?>
+
+
+
+= __('Das ist schief gelaufen: ') ?>
+
+getErrors();
+ foreach($errors as $error) {
+ //echo "\t".json_encode($error);
+ echo "\n\t".$error[array_keys($error)[0]]."\n";
+ }
+}?>
+
+
+= __('Bitte antworte nicht auf diese E-Mail!'); ?>
+
+
+= __('Mit freundlichen Grüßen'); ?>
+Gradido Community Server
\ No newline at end of file
diff --git a/community_server/src/Template/Migrations/add.ctp b/community_server/src/Template/Migrations/add.ctp
new file mode 100644
index 000000000..94a555733
--- /dev/null
+++ b/community_server/src/Template/Migrations/add.ctp
@@ -0,0 +1,23 @@
+
+
+
+ = __('Actions') ?>
+ = $this->Html->link(__('List Migrations'), ['action' => 'index']) ?>
+
+
+
+ = $this->Form->create($migration) ?>
+
+ = __('Add Migration') ?>
+ Form->control('db_version');
+ ?>
+
+ = $this->Form->button(__('Submit')) ?>
+ = $this->Form->end() ?>
+
diff --git a/community_server/src/Template/Migrations/edit.ctp b/community_server/src/Template/Migrations/edit.ctp
new file mode 100644
index 000000000..1e916afa1
--- /dev/null
+++ b/community_server/src/Template/Migrations/edit.ctp
@@ -0,0 +1,29 @@
+
+
+
+ = __('Actions') ?>
+ = $this->Form->postLink(
+ __('Delete'),
+ ['action' => 'delete', $migration->id],
+ ['confirm' => __('Are you sure you want to delete # {0}?', $migration->id)]
+ )
+ ?>
+ = $this->Html->link(__('List Migrations'), ['action' => 'index']) ?>
+
+
+
+ = $this->Form->create($migration) ?>
+
+ = __('Edit Migration') ?>
+ Form->control('db_version');
+ ?>
+
+ = $this->Form->button(__('Submit')) ?>
+ = $this->Form->end() ?>
+
diff --git a/community_server/src/Template/Migrations/index.ctp b/community_server/src/Template/Migrations/index.ctp
new file mode 100644
index 000000000..9d755ecff
--- /dev/null
+++ b/community_server/src/Template/Migrations/index.ctp
@@ -0,0 +1,47 @@
+
+
+
+ = __('Actions') ?>
+ = $this->Html->link(__('New Migration'), ['action' => 'add']) ?>
+
+
+
+
= __('Migrations') ?>
+
+
+
+ = $this->Paginator->sort('id') ?>
+ = $this->Paginator->sort('db_version') ?>
+ = __('Actions') ?>
+
+
+
+
+
+ = $this->Number->format($migration->id) ?>
+ = $this->Number->format($migration->db_version) ?>
+
+ = $this->Html->link(__('View'), ['action' => 'view', $migration->id]) ?>
+ = $this->Html->link(__('Edit'), ['action' => 'edit', $migration->id]) ?>
+ = $this->Form->postLink(__('Delete'), ['action' => 'delete', $migration->id], ['confirm' => __('Are you sure you want to delete # {0}?', $migration->id)]) ?>
+
+
+
+
+
+
+
+
= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?>
+
+
diff --git a/community_server/src/Template/Migrations/migrate.ctp b/community_server/src/Template/Migrations/migrate.ctp
new file mode 100644
index 000000000..d345c9a90
--- /dev/null
+++ b/community_server/src/Template/Migrations/migrate.ctp
@@ -0,0 +1,18 @@
+Migrate DB
+Migrate from Version = $db_version ?>
+
+ Success
+
+ Error
+ = json_encode($result) ?>
+
+ = $this->Html->link('Back to Dashboard', ['controller' => 'Dashboard', 'action' => 'index']) ?>
+
diff --git a/community_server/src/Template/Migrations/view.ctp b/community_server/src/Template/Migrations/view.ctp
new file mode 100644
index 000000000..dc4c5ded3
--- /dev/null
+++ b/community_server/src/Template/Migrations/view.ctp
@@ -0,0 +1,28 @@
+
+
+
+ = __('Actions') ?>
+ = $this->Html->link(__('Edit Migration'), ['action' => 'edit', $migration->id]) ?>
+ = $this->Form->postLink(__('Delete Migration'), ['action' => 'delete', $migration->id], ['confirm' => __('Are you sure you want to delete # {0}?', $migration->id)]) ?>
+ = $this->Html->link(__('List Migrations'), ['action' => 'index']) ?>
+ = $this->Html->link(__('New Migration'), ['action' => 'add']) ?>
+
+
+
+
= h($migration->id) ?>
+
+
+ = __('Id') ?>
+ = $this->Number->format($migration->id) ?>
+
+
+ = __('Db Version') ?>
+ = $this->Number->format($migration->db_version) ?>
+
+
+
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]);
?>
= $this->Form->button(__('Submit')) ?>
diff --git a/community_server/tests/Fixture/MigrationsFixture.php b/community_server/tests/Fixture/MigrationsFixture.php
new file mode 100644
index 000000000..1fab6a133
--- /dev/null
+++ b/community_server/tests/Fixture/MigrationsFixture.php
@@ -0,0 +1,44 @@
+ ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
+ 'db_version' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => true, 'default' => '0', 'comment' => '', 'precision' => null, 'autoIncrement' => null],
+ '_constraints' => [
+ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
+ ],
+ '_options' => [
+ 'engine' => 'InnoDB',
+ 'collation' => 'utf8mb4_unicode_ci'
+ ],
+ ];
+ // @codingStandardsIgnoreEnd
+ /**
+ * Init method
+ *
+ * @return void
+ */
+ public function init()
+ {
+ $this->records = [
+ [
+ 'id' => 1,
+ 'db_version' => 1,
+ ],
+ ];
+ parent::init();
+ }
+}
diff --git a/community_server/tests/TestCase/Controller/MigrationsControllerTest.php b/community_server/tests/TestCase/Controller/MigrationsControllerTest.php
new file mode 100644
index 000000000..4bb794d4d
--- /dev/null
+++ b/community_server/tests/TestCase/Controller/MigrationsControllerTest.php
@@ -0,0 +1,75 @@
+markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test view method
+ *
+ * @return void
+ */
+ public function testView()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test add method
+ *
+ * @return void
+ */
+ public function testAdd()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test edit method
+ *
+ * @return void
+ */
+ public function testEdit()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test delete method
+ *
+ * @return void
+ */
+ public function testDelete()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
diff --git a/community_server/tests/TestCase/Model/Table/MigrationsTableTest.php b/community_server/tests/TestCase/Model/Table/MigrationsTableTest.php
new file mode 100644
index 000000000..f88893585
--- /dev/null
+++ b/community_server/tests/TestCase/Model/Table/MigrationsTableTest.php
@@ -0,0 +1,72 @@
+exists('Migrations') ? [] : ['className' => MigrationsTable::class];
+ $this->Migrations = TableRegistry::getTableLocator()->get('Migrations', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Migrations);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
index 944f8d976..1311fe894 100644
--- a/docker-compose.override.yml
+++ b/docker-compose.override.yml
@@ -26,8 +26,8 @@ services:
#########################################################
login-server:
build:
- target: login_server_debug
- dockerfile: Dockerfile.debug
+ target: login_server_alpine_debug
+ dockerfile: Dockerfile.alpine-debug
security_opt:
- seccomp:unconfined
cap_add:
@@ -35,8 +35,10 @@ services:
volumes:
- ./logs:/var/log/grd_login
- ./login_server/src:/code/src
+ - ./login_server/dependencies:/code/dependencies
+ - ./login_server/scripts:/code/scripts
- ./configs/login_server:/etc/grd_login
- - login_build_conan:/code/build_vol
+ - login_build_alpine:/code/build
#########################################################
@@ -101,5 +103,4 @@ services:
volumes:
frontend_node_modules:
- login_build_conan:
-
+ login_build_alpine:
diff --git a/docu/community-server.api.md b/docu/community-server.api.md
index 9354bf232..11556513b 100644
--- a/docu/community-server.api.md
+++ b/docu/community-server.api.md
@@ -24,12 +24,12 @@ Additional session can be provided as GET-Parameter
{
"state":"success",
"balance":1590.60,
- "decay":15873851,
+ "decay":1587.38,
"decay_date":"2021-04-16T11:47:21+00:00"
}
```
-- `balance` : balance describes gradido
+- `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,6 +59,12 @@ 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",
@@ -68,7 +74,17 @@ Assuming: session is valid
"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.0",
+ "balance": "1000.0",
+ "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
@@ -117,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
@@ -128,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
@@ -139,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
@@ -149,8 +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)
-- `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
+- `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`
@@ -186,7 +204,7 @@ with
{
"session_id" : -127182,
"email": "max.musterman@gmail.de",
- "amount": 1000000,
+ "amount": 100.0,
"memo":"a gift",
"auto_sign": true
}
@@ -196,7 +214,7 @@ with
{
"session_id" : -127182,
"username": "Maxi_786",
- "amount": 1000000,
+ "amount": 100.0,
"memo":"a gift",
"auto_sign": true
}
@@ -206,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
@@ -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"
+}
+````
+
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
diff --git a/frontend/package.json b/frontend/package.json
index 53e5fdbcb..21b02ee2e 100755
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,6 +1,6 @@
{
"name": "bootstrap-vue-gradido-wallet",
- "version": "0.9.4",
+ "version": "1.0.1",
"private": true,
"scripts": {
"start": "node run/server.js",
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index b47b9caf0..d44d64ab3 100755
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -1,20 +1,5 @@
-
-
-
-
- Deutsch
- English
-
-
-
@@ -25,7 +10,6 @@
diff --git a/frontend/src/views/Pages/AccountOverview/GddSend/QrCode.vue b/frontend/src/views/Pages/AccountOverview/GddSend/QrCode.vue
new file mode 100644
index 000000000..edf027aef
--- /dev/null
+++ b/frontend/src/views/Pages/AccountOverview/GddSend/QrCode.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('form.cancel') }}
+
+
+
+
+
+
+
diff --git a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionConfirmation.vue b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionConfirmation.vue
new file mode 100644
index 000000000..1ccbcf8c2
--- /dev/null
+++ b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionConfirmation.vue
@@ -0,0 +1,48 @@
+
+
+
+ {{ $t('form.send_check') }}
+
+
+ {{ email }}
+ {{ $t('form.receiver') }}
+
+
+ {{ amount }} GDD
+ {{ $t('form.amount') }}
+
+
+ {{ memo ? memo : '-' }}
+ {{ $t('form.message') }}
+
+
+ {{ date }}
+ {{ $moment(date).format('DD.MM.YYYY - HH:mm:ss') }}
+ {{ $t('form.date') }}
+
+
+
+
+ {{ $t('form.cancel') }}
+
+
+
+ {{ $t('form.send_now') }}
+
+
+
+
+
+
+
diff --git a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.spec.js b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.spec.js
new file mode 100644
index 000000000..942ff35fc
--- /dev/null
+++ b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.spec.js
@@ -0,0 +1,115 @@
+import { mount } from '@vue/test-utils'
+import TransactionForm from './TransactionForm'
+
+const localVue = global.localVue
+
+describe('GddSend', () => {
+ let wrapper
+
+ const mocks = {
+ $t: jest.fn((t) => t),
+ $moment: jest.fn((m) => ({
+ format: () => m,
+ })),
+ $i18n: {
+ locale: jest.fn(() => 'en'),
+ },
+ $n: jest.fn((n) => String(n)),
+ $store: {
+ state: {
+ email: 'user@example.org',
+ },
+ },
+ }
+
+ const Wrapper = () => {
+ return mount(TransactionForm, { localVue, mocks })
+ }
+
+ describe('mount', () => {
+ beforeEach(() => {
+ wrapper = Wrapper()
+ })
+
+ it('renders the component', () => {
+ expect(wrapper.find('div.transaction-form').exists()).toBeTruthy()
+ })
+
+ describe('transaction form', () => {
+ describe('email field', () => {
+ it('has an input field of type email', () => {
+ expect(wrapper.find('#input-group-1').find('input').attributes('type')).toBe('email')
+ })
+
+ it('has an envelope icon', () => {
+ expect(wrapper.find('#input-group-1').find('svg').attributes('aria-label')).toBe(
+ 'envelope',
+ )
+ })
+
+ it('has a label form.receiver', () => {
+ expect(wrapper.findAll('div.text-left').at(0).text()).toBe('form.receiver')
+ })
+
+ it('has a placeholder "E-Mail"', () => {
+ expect(wrapper.find('#input-group-1').find('input').attributes('placeholder')).toBe(
+ 'E-Mail',
+ )
+ })
+ })
+
+ describe('ammount field', () => {
+ it('has an input field of type number', () => {
+ expect(wrapper.find('#input-group-2').find('input').attributes('type')).toBe('number')
+ })
+
+ it('has an GDD text icon', () => {
+ expect(wrapper.find('#input-group-2').find('div.h3').text()).toBe('GDD')
+ })
+
+ it('has a label form.amount', () => {
+ expect(wrapper.findAll('div.text-left').at(1).text()).toBe('form.amount')
+ })
+
+ it('has a placeholder "0.01"', () => {
+ expect(wrapper.find('#input-group-2').find('input').attributes('placeholder')).toBe(
+ '0.01',
+ )
+ })
+ })
+
+ describe('message text box', () => {
+ it('has an textarea field', () => {
+ expect(wrapper.find('#input-group-3').find('textarea').exists()).toBeTruthy()
+ })
+
+ it('has an chat-right-text icon', () => {
+ expect(wrapper.find('#input-group-3').find('svg').attributes('aria-label')).toBe(
+ 'chat right text',
+ )
+ })
+
+ it('has a label form.memo', () => {
+ expect(wrapper.findAll('div.text-left').at(2).text()).toBe('form.memo')
+ })
+ })
+
+ describe('cancel button', () => {
+ it('has a cancel button', () => {
+ expect(wrapper.find('button[type="reset"]').exists()).toBeTruthy()
+ })
+
+ it('has the text "form.cancel"', () => {
+ expect(wrapper.find('button[type="reset"]').text()).toBe('form.reset')
+ })
+
+ it.skip('clears the email field on click', async () => {
+ wrapper.find('#input-group-1').find('input').setValue('someone@watches.tv')
+ wrapper.find('button[type="reset"]').trigger('click')
+ await wrapper.vm.$nextTick()
+ expect(wrapper.vm.form.email).toBeNull()
+ })
+ })
+ })
+ })
+})
diff --git a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.vue b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.vue
new file mode 100644
index 000000000..3a38d49db
--- /dev/null
+++ b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionForm.vue
@@ -0,0 +1,187 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('form.receiver') }}
+
+ {{ error }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('form.amount') }}
+
+ {{ error }}
+
+
+
+
+ GDD
+
+
+
+
+
+
+ {{ $t('form.memo') }}
+
+ {{ error }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('form.reset') }}
+
+
+
+
+ {{ $t('form.send_now') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/Pages/AccountOverview/GddSend/TransactionResult.vue b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionResult.vue
new file mode 100644
index 000000000..11d52fef5
--- /dev/null
+++ b/frontend/src/views/Pages/AccountOverview/GddSend/TransactionResult.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
+ {{ $t('form.thx') }}
+
+ {{ $t('form.send_transaction_success') }}
+
+
+ {{ $t('form.close') }}
+
+
+
+
+
+
+
+
+ {{ $t('form.sorry') }}
+
+ {{ $t('form.send_transaction_error') }}
+
+
+ {{ $t('form.close') }}
+
+
+
+
+
+
diff --git a/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js b/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js
index 9adc3b4ca..b414f4e93 100644
--- a/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js
+++ b/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js
@@ -24,12 +24,30 @@ describe('GddStatus', () => {
wrapper = Wrapper()
})
- it('it displays the ammount of GDD', () => {
- expect(wrapper.findAll('div.card-body').at(0).text()).toEqual('1234 GDD')
+ describe('balance is loading', () => {
+ it('it displays em-dash as the ammount of GDD', () => {
+ expect(wrapper.findAll('div.card-body').at(0).text()).toEqual('— GDD')
+ })
+
+ it('it displays em-dash as the ammount of GDT', () => {
+ expect(wrapper.findAll('div.card-body').at(1).text()).toEqual('— GDT')
+ })
})
- it('it displays the ammount of GDT', () => {
- expect(wrapper.findAll('div.card-body').at(1).text()).toEqual('9876 GDT')
+ describe('balance is loaded', () => {
+ beforeEach(() => {
+ wrapper.setProps({
+ pending: false,
+ })
+ })
+
+ it('it displays the ammount of GDD', () => {
+ expect(wrapper.findAll('div.card-body').at(0).text()).toEqual('1234 GDD')
+ })
+
+ it('it displays the ammount of GDT', () => {
+ expect(wrapper.findAll('div.card-body').at(1).text()).toEqual('9876 GDT')
+ })
})
})
})
diff --git a/frontend/src/views/Pages/AccountOverview/GddStatus.vue b/frontend/src/views/Pages/AccountOverview/GddStatus.vue
index 8698d1fdc..32fccce28 100644
--- a/frontend/src/views/Pages/AccountOverview/GddStatus.vue
+++ b/frontend/src/views/Pages/AccountOverview/GddStatus.vue
@@ -2,24 +2,14 @@
-
- {{ $n(balance) }} GDD
-
+
+ {{ pending ? '—' : $n(balance) }} GDD
+
-
- {{ $n(GdtBalance) }} GDT
-
+
+ {{ pending ? '—' : $n(GdtBalance) }} GDT
+
@@ -31,6 +21,10 @@ export default {
props: {
balance: { type: Number, default: 0 },
GdtBalance: { type: Number, default: 0 },
+ pending: {
+ type: Boolean,
+ default: true,
+ },
},
}
diff --git a/frontend/src/views/Pages/AccountOverview/GddTable.vue b/frontend/src/views/Pages/AccountOverview/GddTable.vue
index 194315b31..f516f7cbb 100644
--- a/frontend/src/views/Pages/AccountOverview/GddTable.vue
+++ b/frontend/src/views/Pages/AccountOverview/GddTable.vue
@@ -88,11 +88,9 @@
-
-
- {{ $t('transaction.nullTransactions') }}
-
-
+
+ {{ $t('transaction.nullTransactions') }}
+
@@ -102,7 +100,7 @@ export default {
name: 'GddTable',
props: {
transactions: { default: [] },
- max: { type: Number, default: 25 },
+ max: { type: Number, default: 1000 },
timestamp: { type: Number, default: 0 },
transactionCount: { type: Number, default: 0 },
},
diff --git a/frontend/src/views/Pages/ForgotPassword.vue b/frontend/src/views/Pages/ForgotPassword.vue
index 484b50629..32331d080 100644
--- a/frontend/src/views/Pages/ForgotPassword.vue
+++ b/frontend/src/views/Pages/ForgotPassword.vue
@@ -62,7 +62,7 @@ export default {
async onSubmit() {
const result = await loginAPI.sendEmail(this.form.email)
if (result.success) {
- this.$router.push({ path: '/thx', params: { id: 'resetmail' } })
+ this.$router.push('/thx/password')
} else {
alert(result.result)
}
diff --git a/frontend/src/views/Pages/Login.spec.js b/frontend/src/views/Pages/Login.spec.js
index c95aa5a4c..0d94840b0 100644
--- a/frontend/src/views/Pages/Login.spec.js
+++ b/frontend/src/views/Pages/Login.spec.js
@@ -1,5 +1,4 @@
import { mount, RouterLinkStub } from '@vue/test-utils'
-import Vuex from 'vuex'
import flushPromises from 'flush-promises'
import Login from './Login'
@@ -16,20 +15,12 @@ describe('Login', () => {
$t: jest.fn((t) => t),
}
- const state = {
- loginfail: false,
- }
-
- const store = new Vuex.Store({
- state,
- })
-
const stubs = {
RouterLink: RouterLinkStub,
}
const Wrapper = () => {
- return mount(Login, { localVue, mocks, store, stubs })
+ return mount(Login, { localVue, mocks, stubs })
}
describe('mount', () => {
diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue
index b04bce7b0..a6d795bb1 100755
--- a/frontend/src/views/Pages/Login.vue
+++ b/frontend/src/views/Pages/Login.vue
@@ -34,15 +34,22 @@
v-model="model.email"
>
-
+
+
+
+
+
+
+
+
+
@@ -98,9 +105,13 @@ export default {
},
loginfail: false,
allowRegister: CONFIG.ALLOW_REGISTER,
+ passwordVisible: false,
}
},
methods: {
+ togglePasswordVisibility() {
+ this.passwordVisible = !this.passwordVisible
+ },
async onSubmit() {
// error info ausschalten
this.loginfail = false
@@ -111,7 +122,7 @@ export default {
if (result.success) {
this.$store.dispatch('login', {
sessionId: result.result.data.session_id,
- email: this.model.email,
+ user: result.result.data.user,
})
this.$router.push('/overview')
loader.hide()
diff --git a/frontend/src/views/Pages/Register.spec.js b/frontend/src/views/Pages/Register.spec.js
index dcb97cf42..3d4296567 100644
--- a/frontend/src/views/Pages/Register.spec.js
+++ b/frontend/src/views/Pages/Register.spec.js
@@ -1,5 +1,4 @@
import { mount, RouterLinkStub } from '@vue/test-utils'
-import Vuex from 'vuex'
import flushPromises from 'flush-promises'
import Register from './Register'
@@ -16,20 +15,12 @@ describe('Register', () => {
$t: jest.fn((t) => t),
}
- const state = {
- // loginfail: false,
- }
-
- const store = new Vuex.Store({
- state,
- })
-
const stubs = {
RouterLink: RouterLinkStub,
}
const Wrapper = () => {
- return mount(Register, { localVue, mocks, store, stubs })
+ return mount(Register, { localVue, mocks, stubs })
}
describe('mount', () => {
diff --git a/frontend/src/views/Pages/Register.vue b/frontend/src/views/Pages/Register.vue
index 42761ec99..d7b9ab8f0 100755
--- a/frontend/src/views/Pages/Register.vue
+++ b/frontend/src/views/Pages/Register.vue
@@ -97,7 +97,6 @@
-
diff --git a/frontend/src/views/Pages/thx.vue b/frontend/src/views/Pages/thx.vue
index 1a5a7112b..a4a31ff41 100644
--- a/frontend/src/views/Pages/thx.vue
+++ b/frontend/src/views/Pages/thx.vue
@@ -1,28 +1,52 @@
-
+
diff --git a/login_server/CMakeLists.txt b/login_server/CMakeLists.txt
index 4502249e5..c1b55d9c7 100644
--- a/login_server/CMakeLists.txt
+++ b/login_server/CMakeLists.txt
@@ -2,10 +2,17 @@ cmake_minimum_required(VERSION 3.18.2)
project(Gradido_LoginServer C CXX)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin" )
-SET ( CMAKE_CXX_FLAGS "-std=c++17" )
+SET(CMAKE_CXX_FLAGS "-std=c++17" )
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+IF(WIN32)
+ set(CMAKE_CXX_FLAGS "/MP /EHsc")
+ENDIF()
+
+set(INSTALL_BINDIR "bin")
+set(INSTALL_PLUGINDIR "bin")
+
include_directories(
"dependencies"
"dependencies/tinf/src/"
@@ -14,13 +21,119 @@ include_directories(
"dependencies/spirit-po/include"
"dependencies/grpc/include"
"dependencies/grpc/third_party/protobuf/src"
- "src/cpp/proto"
+ "dependencies/grpc/third_party/googletest/googletest/include"
+ "build"
+ "build/proto"
)
-#if(WIN32)
-#include_directories("dependencies/mariadb-connector-c/include", "dependencies/mariadb-connector-c/build/include")
-set(MYSQL_INCLUDE_DIR "dependencies/mariadb-connector-c/include")
-#endif(WIN32)
+IF(UNIX)
+ include_directories(
+ "dependencies/poco/Crypto/include"
+ "dependencies/poco/Data/include"
+ "dependencies/poco/Util/include"
+ "dependencies/poco/Foundation/include"
+ "dependencies/poco/JSON/include"
+ "dependencies/poco/Net/include"
+ "dependencies/poco/NetSSL_OpenSSL/include"
+ )
+ENDIF()
+############################## config and add grpc ###################################
+
+set(GRPC_PATH "${DEP_PATH}/grpc/build")
+set(GRPC_ABSL_PATH "${GRPC_PATH}/third_party/abseil-cpp/absl/types")
+set(GRPC_CARES_PATH "${GRPC_PATH}/third_party/cares/cares/lib")
+set(GRPC_BORING_SSL_PATH "${GRPC_PATH}/third_party/boringssl-with-bazel")
+set(GRPC_RE2_PATH "${GRPC_PATH}/third_party/re2")
+set(GRPC_PROTOBUF_PATH "${GRPC_PATH}/third_party/protobuf")
+
+if(WIN32)
+ set(GRPC_PATH "${GRPC_PATH}/Debug")
+ set(GRPC_ABSL_PATH "${GRPC_ABSL_PATH}/Debug")
+ set(GRPC_CARES_PATH "${GRPC_CARES_PATH}/Debug")
+ set(GRPC_BORING_SSL_PATH "${GRPC_CGRPC_BORING_SSL_PATHARES_PATH}/Debug")
+ set(GRPC_RE2_PATH "${GRPC_RE2_PATH}/Debug")
+ set(GRPC_PROTOBUF_DEBUG_PATH "${GRPC_PROTOBUF_PATH}/Debug")
+endif()
+
+
+set(BUILD_TESTING OFF)
+#set(gRPC_SSL_PROVIDER "package")
+add_subdirectory("dependencies/grpc/")
+#set(gRPC_SSL_PROVIDER "package")
+message(STATUS "Using gRPC via add_subdirectory.")
+
+set(GRPC_LIBS libprotobuf grpc++_reflection grpc++)
+
+############################## parse protobuf files ###################################
+
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/proto GRADIDO_PROTO_MODEL_PATH)
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/proto/hedera/hedera-protobuf/src/main/proto HEDERA_PROTO_MODEL_PATH)
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/proto PROTOBINDING_PATH)
+file(MAKE_DIRECTORY ${PROTOBINDING_PATH})
+file(MAKE_DIRECTORY ${PROTOBINDING_PATH}/gradido)
+file(MAKE_DIRECTORY ${PROTOBINDING_PATH}/hedera)
+
+FILE(GLOB DATAMODEL_GRADIDO_PROTOS "${GRADIDO_PROTO_MODEL_PATH}/gradido/*.proto")
+FILE(GLOB DATAMODEL_HEDERA_PROTOS "${HEDERA_PROTO_MODEL_PATH}/*.proto")
+
+IF(WIN32)
+ find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin PATHS "build/dependencies/grpc/bin/Debug")
+ find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin PATHS "build/dependencies/grpc/bin/Release")
+ find_program(PROTOBUF_PROTOC_EXECUTABLE protoc PATHS "build/dependencies/grpc/third_party/protobuf/bin/Debug" )
+ find_program(PROTOBUF_PROTOC_EXECUTABLE protoc PATHS "build/dependencies/grpc/third_party/protobuf/bin/Release" )
+ELSE()
+ find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin PATHS "build/dependencies/grpc/bin")
+ find_program(PROTOBUF_PROTOC_EXECUTABLE protoc PATHS "build/dependencies/grpc/third_party/protobuf/bin" )
+ENDIF()
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/grpc/third_party/protobuf/src GOOGLE_PROTOBUF_INCLUDES)
+MESSAGE("protoc: ${PROTOBUF_PROTOC_EXECUTABLE} in build/dependencies/grpc/bin/${CMAKE_BUILD_TYPE}")
+FOREACH(proto ${DATAMODEL_GRADIDO_PROTOS})
+ FILE(TO_NATIVE_PATH ${proto} proto_native)
+ get_filename_component(proto_parsed ${proto} NAME_WLE)
+ FILE(TO_NATIVE_PATH ${PROTOBINDING_PATH}/gradido/${proto_parsed}.pb.h proto_parsed_native)
+
+ IF(${proto_native} IS_NEWER_THAN ${proto_parsed_native})
+ EXECUTE_PROCESS(
+ COMMAND
+ ${PROTOBUF_PROTOC_EXECUTABLE}
+ --proto_path=${GRADIDO_PROTO_MODEL_PATH}
+ --cpp_out=${PROTOBINDING_PATH}
+ ${proto_native}
+ RESULT_VARIABLE rv
+ )
+ # Optional, but that can show the user if something have gone wrong with the proto generation
+ IF(${rv})
+ MESSAGE("Generation of data model returned ${rv} for proto ${proto_native}")
+ ENDIF()
+ ENDIF()
+
+ENDFOREACH(proto)
+
+FOREACH(proto ${DATAMODEL_HEDERA_PROTOS})
+ FILE(TO_NATIVE_PATH ${proto} proto_native)
+ get_filename_component(proto_parsed ${proto} NAME_WLE)
+ FILE(TO_NATIVE_PATH ${PROTOBINDING_PATH}/hedera/${proto_parsed}.pb.h proto_parsed_native)
+ IF(${proto_native} IS_NEWER_THAN ${proto_parsed_native})
+ EXECUTE_PROCESS(
+ COMMAND
+ ${PROTOBUF_PROTOC_EXECUTABLE}
+ --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
+ --proto_path=${HEDERA_PROTO_MODEL_PATH}
+ --proto_path=${GOOGLE_PROTOBUF_INCLUDES}
+ --cpp_out=${PROTOBINDING_PATH}/hedera
+ --grpc_out ${PROTOBINDING_PATH}/hedera
+ ${proto_native}
+ RESULT_VARIABLE rv
+ )
+ # Optional, but that can show the user if something have gone wrong with the proto generation
+ IF(${rv})
+ MESSAGE("Generation of data model returned ${rv} for proto ${proto_native}")
+ ENDIF()
+ ENDIF()
+ENDFOREACH(proto)
+
+
+############################## bind source files ###################################
FILE(GLOB CONTROLLER "src/cpp/controller/*.cpp" "src/cpp/controller/*.h")
FILE(GLOB TINF "dependencies/tinf/src/*.c" "dependencies/tinf/src/*.h")
@@ -37,8 +150,8 @@ FILE(GLOB MODEL_GRADIDO "src/cpp/model/gradido/*.h" "src/cpp/model/gradido/*.cpp
FILE(GLOB CRYPTO "src/cpp/Crypto/*.h" "src/cpp/Crypto/*.cpp")
FILE(GLOB MAIN "src/cpp/*.cpp" "src/cpp/*.c" "src/cpp/*.h")
FILE(GLOB MYSQL "src/cpp/MySQL/*.cpp" "src/cpp/MySQL/*.h" "src/cpp/MySQL/Poco/*.h")
-FILE(GLOB PROTO_GRADIDO "src/cpp/proto/gradido/*.cc" "src/cpp/proto/gradido/*.h")
-FILE(GLOB PROTO_HEDERA "src/cpp/proto/hedera/*.cc" "src/cpp/proto/hedera/*.h")
+FILE(GLOB PROTO_GRADIDO "build/proto/gradido/*.cc" "build/proto/gradido/*.h")
+FILE(GLOB PROTO_HEDERA "build/proto/hedera/*.cc" "build/proto/hedera/*.h")
# used only for test project
FILE(GLOB TEST "src/cpp/test/*.cpp" "src/cpp/test/*.h")
@@ -84,12 +197,15 @@ if(MSVC)
source_group("Test" FILES ${TEST})
endif()
-
-include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
-conan_basic_setup()
-
+IF(WIN32)
+ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+ conan_basic_setup()
+ #add_compile_definitions(POCO_NETSSL_WIN)
+ENDIF()
add_executable(Gradido_LoginServer ${LOCAL_SRCS})
+
+############################## config and add mariadb ###################################
set(CLIENT_PLUGIN_DIALOG OFF)
set(CLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD OFF)
set(CLIENT_PLUGIN_REMOTE_IO OFF)
@@ -111,99 +227,34 @@ add_subdirectory("dependencies/mariadb-connector-c")
set(DEP_PATH "dependencies")
set(MARIADB_CONNECTOR_PATH "${DEP_PATH}/mariadb-connector-c/build/libmariadb")
-set(GRPC_PATH "${DEP_PATH}/grpc/build")
-set(GRPC_ABSL_PATH "${GRPC_PATH}/third_party/abseil-cpp/absl/types")
-set(GRPC_CARES_PATH "${GRPC_PATH}/third_party/cares/cares/lib")
-set(GRPC_BORING_SSL_PATH "${GRPC_PATH}/third_party/boringssl-with-bazel")
-set(GRPC_RE2_PATH "${GRPC_PATH}/third_party/re2")
-set(GRPC_PROTOBUF_PATH "${GRPC_PATH}/third_party/protobuf")
+#if(WIN32)
+ #find_library(MYSQL_LIBRARIES mariadbclient PATHS "${MARIADB_CONNECTOR_PATH}/Release" REQUIRED)
+ #find_library(COMPILED_MARIADB_CLIENT_DEBUG mariadbclient PATHS "${MARIADB_CONNECTOR_PATH}/Debug" REQUIRED)
+#endif()
+
+############################## config and add poco ###################################
+#SET(SOME_EXPAT_OPTION OFF CACHE BOOL "Use some expat option")
+IF(UNIX)
+ SET(ENABLE_MONGODB OFF CACHE BOOL "" FORCE)
+ SET(ENABLE_DATA_SQLITE OFF CACHE BOOL "" FORCE)
+ SET(ENABLE_REDIS OFF CACHE BOOL "" FORCE)
+ SET(ENABLE_PAGECOMPILER_FILE2PAGE OFF CACHE BOOL "" FORCE)
+ add_subdirectory("dependencies/poco")
+
+ set(POCO_LIBS PocoFoundation PocoUtil PocoNet PocoNetSSL PocoData)
+ENDIF()
+############################## build login server ###################################
+
+target_link_libraries(Gradido_LoginServer ${GRPC_LIBS})
if(WIN32)
-
- find_library(MYSQL_LIBRARIES mariadbclient PATHS "${MARIADB_CONNECTOR_PATH}/Release" REQUIRED)
- find_library(COMPILED_MARIADB_CLIENT_DEBUG mariadbclient PATHS "${MARIADB_CONNECTOR_PATH}/Debug" REQUIRED)
-
- find_library(CONAN_OPENSSL_SSL ssleay32 PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
- find_library(CONAN_OPENSSL_CRYPTO libeay32 PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
-
- set(GRPC_PATH "${GRPC_PATH}/Debug")
- set(GRPC_ABSL_PATH "${GRPC_ABSL_PATH}/Debug")
- set(GRPC_CARES_PATH "${GRPC_CARES_PATH}/Debug")
- set(GRPC_BORING_SSL_PATH "${GRPC_CGRPC_BORING_SSL_PATHARES_PATH}/Debug")
- set(GRPC_RE2_PATH "${GRPC_RE2_PATH}/Debug")
- set(GRPC_PROTOBUF_DEBUG_PATH "${GRPC_PROTOBUF_PATH}/Debug")
-
-
- list(REMOVE_ITEM CONAN_LIBS "libeay32.lib")
- list(REMOVE_ITEM CONAN_LIBS "ssleay32.lib")
-
-
-else()
- #find_package(MariaDBClient PATHS "dependencies/cmake-modules")
- #find_library(MYSQL_LIBRARIES libmariadb.so PATHS ${MARIADB_CONNECTOR_PATH} REQUIRED)
- find_library(CONAN_OPENSSL_SSL ssl PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
- find_library(CONAN_OPENSSL_CRYPTO crypto PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
- set(GRPC_PROTOBUF_DEBUG_PATH "${GRPC_PROTOBUF_PATH}")
-
- list(REMOVE_ITEM CONAN_LIBS "ssl")
- list(REMOVE_ITEM CONAN_LIBS "crypto")
- list(REMOVE_ITEM CONAN_LIBS "dl")
-
-# find_library(MYSQL_LIBRARIES libmariadb.so PATHS ${MARIADB_CONNECTOR_PATH} REQUIRED)
- find_library(CONAN_OPENSSL_SSL ssl PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
- find_library(CONAN_OPENSSL_CRYPTO crypto PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
- set(GRPC_PROTOBUF_DEBUG_PATH "${GRPC_PROTOBUF_PATH}")
-
- list(REMOVE_ITEM CONAN_LIBS "ssl")
- list(REMOVE_ITEM CONAN_LIBS "crypto")
- list(REMOVE_ITEM CONAN_LIBS "dl")
-
-endif()
-
-# load same ssl version like used from poco
-#find_package(OpenSSL PATHS "../" NO_DEFAULT_PATH)
-
-
-set(CONAN_OPENSSL_CUSTOM_LIBS
- ${CONAN_OPENSSL_SSL}
- ${CONAN_OPENSSL_CRYPTO}
-)
-include_directories(${CONAN_INCLUDE_DIRS_OPENSSL})
-# build grpc
-
-
-
-if(WIN32)
-
- set(CMAKE_CXX_FLAGS "/MP /EHsc")
- #set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
- #set(CMAKE_CXX_FLAGS_RELEASE "-O3")
-
-else()
-
- set(INSTALL_BINDIR "bin")
- set(INSTALL_PLUGINDIR "bin")
- target_link_libraries(Gradido_LoginServer ${CONAN_OPENSSL_CUSTOM_LIBS})
-
-endif()
-
-set(BUILD_TESTING OFF)
-set(gRPC_SSL_PROVIDER "package")
-add_subdirectory("dependencies/grpc/")
-set(gRPC_SSL_PROVIDER "package")
-message(STATUS "Using gRPC via add_subdirectory.")
-
-set(GRPC_LIBS libprotobuf grpc++_reflection grpc++)
-target_link_libraries(Gradido_LoginServer ${CONAN_LIBS})
-
-if(WIN32)
- TARGET_LINK_LIBRARIES(Gradido_LoginServer optimized ${MYSQL_LIBRARIES} Shlwapi)
- TARGET_LINK_LIBRARIES(Gradido_LoginServer debug ${COMPILED_MARIADB_CLIENT_DEBUG} Shlwapi)
- TARGET_LINK_LIBRARIES(Gradido_LoginServer debug ${GRPC_LIBS} ${PROTOBUF_DEBUG_LIBS})
+ target_link_libraries(Gradido_LoginServer mariadbclient ${CONAN_LIBS})
+ #TARGET_LINK_LIBRARIES(Gradido_LoginServer optimized ${MYSQL_LIBRARIES} Shlwapi)
+ #TARGET_LINK_LIBRARIES(Gradido_LoginServer debug ${COMPILED_MARIADB_CLIENT_DEBUG} Shlwapi)
else() # unix
- target_link_libraries(Gradido_LoginServer libmariadb ${GRPC_LIBS} ${CMAKE_DL_LIBS} ${PROTOBUF_LIBS})
+ target_link_libraries(Gradido_LoginServer ${POCO_LIBS} libmariadb sodium)
endif()
# install
@@ -228,15 +279,15 @@ enable_testing()
add_executable(Gradido_LoginServer_Test ${LOCAL_SRCS} ${LOCAL_TEST_SRC})
target_compile_definitions(Gradido_LoginServer_Test PUBLIC "_TEST_BUILD")
-target_link_libraries(Gradido_LoginServer_Test ${CONAN_LIBS} )
-
+target_link_libraries(Gradido_LoginServer_Test ${GRPC_LIBS} )
if(WIN32)
- TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test optimized ${MYSQL_LIBRARIES} Shlwapi)
- TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test debug ${COMPILED_MARIADB_CLIENT_DEBUG} Shlwapi)
- TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test debug ${GRPC_LIBS} ${PROTOBUF_DEBUG_LIBS})
+ target_link_libraries(Gradido_LoginServer_Test ${CONAN_LIBS} )
+ #TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test optimized ${MYSQL_LIBRARIES} Shlwapi)
+ #TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test debug ${COMPILED_MARIADB_CLIENT_DEBUG} Shlwapi)
+ #TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test debug ${GRPC_LIBS} ${PROTOBUF_DEBUG_LIBS})
else()
- target_link_libraries(Gradido_LoginServer_Test libmariadb ${GRPC_LIBS} ${CMAKE_DL_LIBS} ${PROTOBUF_LIBS})
+ target_link_libraries(Gradido_LoginServer_Test ${POCO_LIBS} libmariadb sodium)
endif()
add_test(NAME main COMMAND Gradido_LoginServer_Test)
diff --git a/login_server/CMakeLists.txt.lib b/login_server/CMakeLists.txt.lib
new file mode 100644
index 000000000..6de10f72e
--- /dev/null
+++ b/login_server/CMakeLists.txt.lib
@@ -0,0 +1,189 @@
+cmake_minimum_required(VERSION 3.18.2)
+project(Gradido_LoginServer C CXX)
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin" )
+
+SET ( CMAKE_CXX_FLAGS "-std=c++17" )
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+if(WIN32)
+ set(CMAKE_CXX_FLAGS "/MP /EHsc")
+ set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O3")
+else()
+ set(INSTALL_BINDIR "bin")
+ set(INSTALL_PLUGINDIR "bin")
+endif()
+
+include_directories(
+ "dependencies"
+ "dependencies/tinf/src"
+ "dependencies/spirit-po/include"
+ "/usr/local/include/mariadb"
+ "build"
+ "build/proto"
+)
+
+############################## config and add grpc ###################################
+find_package(Protobuf REQUIRED)
+include_directories(${Protobuf_INCLUDE_DIRS})
+
+FIND_PACKAGE(gRPC CONFIG REQUIRED)
+find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin)
+
+set(PROTOBUF_LIBS protobuf::libprotobuf protobuf::libprotobuf-lite protobuf::libprotoc)
+
+############################## parse proto files ###################################
+
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/proto GRADIDO_PROTO_MODEL_PATH)
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/proto/hedera/hedera-protobuf/src/main/proto HEDERA_PROTO_MODEL_PATH)
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/proto PROTOBINDING_PATH)
+file(MAKE_DIRECTORY ${PROTOBINDING_PATH})
+file(MAKE_DIRECTORY ${PROTOBINDING_PATH}/gradido)
+file(MAKE_DIRECTORY ${PROTOBINDING_PATH}/hedera)
+
+FILE(GLOB DATAMODEL_GRADIDO_PROTOS "${GRADIDO_PROTO_MODEL_PATH}/gradido/*.proto")
+FILE(GLOB DATAMODEL_HEDERA_PROTOS "${HEDERA_PROTO_MODEL_PATH}/*.proto")
+
+FOREACH(proto ${DATAMODEL_GRADIDO_PROTOS})
+ FILE(TO_NATIVE_PATH ${proto} proto_native)
+ get_filename_component(proto_parsed ${proto} NAME_WLE)
+ FILE(TO_NATIVE_PATH ${PROTOBINDING_PATH}/gradido/${proto_parsed}.pb.h proto_parsed_native)
+
+ IF(${proto_native} IS_NEWER_THAN ${proto_parsed_native})
+ EXECUTE_PROCESS(
+ COMMAND
+ ${PROTOBUF_PROTOC_EXECUTABLE}
+ --proto_path=${GRADIDO_PROTO_MODEL_PATH}
+ --cpp_out=${PROTOBINDING_PATH}
+ ${proto_native}
+ RESULT_VARIABLE rv
+ )
+ # Optional, but that can show the user if something have gone wrong with the proto generation
+ IF(${rv})
+ MESSAGE("Generation of data model returned ${rv} for proto ${proto_native}")
+ ENDIF()
+ ENDIF()
+
+ENDFOREACH(proto)
+
+FOREACH(proto ${DATAMODEL_HEDERA_PROTOS})
+ FILE(TO_NATIVE_PATH ${proto} proto_native)
+ get_filename_component(proto_parsed ${proto} NAME_WLE)
+ FILE(TO_NATIVE_PATH ${PROTOBINDING_PATH}/hedera/${proto_parsed}.pb.h proto_parsed_native)
+ IF(${proto_native} IS_NEWER_THAN ${proto_parsed_native})
+ EXECUTE_PROCESS(
+ COMMAND
+ ${PROTOBUF_PROTOC_EXECUTABLE}
+ --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
+ --proto_path=${HEDERA_PROTO_MODEL_PATH}
+ --proto_path=${GOOGLE_PROTOBUF_INCLUDES}
+ --cpp_out=${PROTOBINDING_PATH}/hedera
+ --grpc_out ${PROTOBINDING_PATH}/hedera
+ ${proto_native}
+ RESULT_VARIABLE rv
+ )
+ # Optional, but that can show the user if something have gone wrong with the proto generation
+ IF(${rv})
+ MESSAGE("Generation of data model returned ${rv} for proto ${proto_native}")
+ ENDIF()
+ ENDIF()
+ENDFOREACH(proto)
+
+############################## include src files ###################################
+#set(MYSQL_INCLUDE_DIR "dependencies/mariadb-connector-c/include")
+
+FILE(GLOB CONTROLLER "src/cpp/controller/*.cpp" "src/cpp/controller/*.h")
+FILE(GLOB TINF "dependencies/tinf/src/*.c" "dependencies/tinf/src/*.h")
+FILE(GLOB HTTPInterface "src/cpp/HTTPInterface/*.h" "src/cpp/HTTPInterface/*.cpp")
+FILE(GLOB JSONInterface "src/cpp/JSONInterface/*.h" "src/cpp/JSONInterface/*.cpp")
+FILE(GLOB TASKS "src/cpp/tasks/*.cpp" "src/cpp/tasks/*.h")
+FILE(GLOB SINGLETON_MANAGER "src/cpp/SingletonManager/*.h" "src/cpp/SingletonManager/*.cpp")
+FILE(GLOB LIB_SRC "src/cpp/lib/*.h" "src/cpp/lib/*.cpp")
+FILE(GLOB MODEL "src/cpp/model/*.h" "src/cpp/model/*.cpp")
+FILE(GLOB MODEL_TABLE "src/cpp/model/table/*.h" "src/cpp/model/table/*.cpp")
+FILE(GLOB MODEL_EMAIL "src/cpp/model/email/*.h" "src/cpp/model/email/*.cpp")
+FILE(GLOB MODEL_HEDERA "src/cpp/model/hedera/*.h" "src/cpp/model/hedera/*.cpp")
+FILE(GLOB MODEL_GRADIDO "src/cpp/model/gradido/*.h" "src/cpp/model/gradido/*.cpp")
+FILE(GLOB CRYPTO "src/cpp/Crypto/*.h" "src/cpp/Crypto/*.cpp")
+FILE(GLOB MAIN "src/cpp/*.cpp" "src/cpp/*.c" "src/cpp/*.h")
+FILE(GLOB MYSQL "src/cpp/MySQL/*.cpp" "src/cpp/MySQL/*.h" "src/cpp/MySQL/Poco/*.h")
+FILE(GLOB PROTO_GRADIDO "${PROTOBINDING_PATH}/gradido/*.cc" "${PROTOBINDING_PATH}/gradido/*.h")
+FILE(GLOB PROTO_HEDERA "${PROTOBINDING_PATH}/hedera/*.cc" "${PROTOBINDING_PATH}/hedera/*.h")
+
+# used only for test project
+FILE(GLOB TEST "src/cpp/test/*.cpp" "src/cpp/test/*.h")
+FILE(GLOB TEST_CRYPTO "src/cpp/test/crypto/*.cpp" "src/cpp/test/crypto/*.h")
+FILE(GLOB TEST_MODEL "src/cpp/test/model/*.cpp" "src/cpp/test/model/*.h")
+FILE(GLOB TEST_MODEL_TABLE "src/cpp/test/model/table/*.cpp" "src/cpp/test/model/table/*.h")
+FILE(GLOB TEST_CONTROLLER "src/cpp/test/controller/*.cpp" "src/cpp/test/controller/*.h")
+
+SET(LOCAL_SRCS
+ ${CONTROLLER} ${TINF} ${MAIN} ${HTTPInterface}
+ ${JSONInterface} ${CRYPTO}
+ ${MODEL} ${MODEL_TABLE} ${MODEL_EMAIL} ${MODEL_HEDERA} ${MODEL_GRADIDO}
+ ${SINGLETON_MANAGER} ${LIB_SRC} ${MYSQL} ${TASKS}
+ ${PROTO_GRADIDO} ${PROTO_HEDERA}
+)
+SET(LOCAL_TEST_SRC
+ ${TEST} ${TEST_CRYPTO} ${TEST_MODEL} ${TEST_MODEL_TABLE} ${TEST_CONTROLLER}
+)
+aux_source_directory("src/cpp" LOCAL_SRCS)
+
+if(MSVC)
+ # src
+ source_group("controller" FILES ${CONTROLLER})
+ source_group("proto\\gradido" FILES ${PROTO_GRADIDO})
+ source_group("proto\\hedera" FILES ${PROTO_HEDERA})
+ source_group("tinf" FILES ${TINF})
+ source_group("Crypto" FILES ${CRYPTO})
+ source_group("tasks" FILES ${TASKS})
+ source_group("model\\table" FILES ${MODEL_TABLE})
+ source_group("model\\email" FILES ${MODEL_EMAIL})
+ source_group("model\\hedera" FILES ${MODEL_HEDERA})
+ source_group("model\\gradido" FILES ${MODEL_GRADIDO})
+ source_group("model" FILES ${MODEL})
+ source_group("mysql" FILES ${MYSQL})
+ source_group("SingletonManager" FILES ${SINGLETON_MANAGER})
+ source_group("lib" FILES ${LIB_SRC})
+ source_group("HTTP-Interface" FILES ${HTTPInterface})
+ source_group("Json-Interface" FILES ${JSONInterface})
+ source_group("Test\\crypto" FILES ${TEST_CRYPTO})
+ source_group("Test\\model\\table" FILES ${TEST_MODEL_TABLE})
+ source_group("Test\\model" FILES ${TEST_MODEL})
+ source_group("Test\\controller" FILES ${TEST_CONTROLLER})
+ source_group("Test" FILES ${TEST})
+endif()
+
+add_executable(Gradido_LoginServer ${LOCAL_SRCS})
+
+############################## find mariadb ###################################
+find_library(MYSQL_LIBRARIES mariadb PATHS "/usr/local/lib/mariadb" REQUIRED)
+############################## config and add poco ###################################
+set(BUILD_LIB_PATH "(/usr/local/lib")
+
+IF(CMAKE_BUILD_TYPE MATCHES Debug)
+ find_library(POCO_FOUNDATION_LIB PocoFoundationd PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_UTIL_LIB PocoUtild PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_NET_SSL_LIB PocoNetSSLd PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_DATA_LIB PocoDatad PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_JSON_LIB PocoJSONd PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_NET_LIB PocoNetd PATHS ${BUILD_LIB_PATH} REQUIRED)
+ message("use Poco Debug libs")
+ELSE()
+ find_library(POCO_FOUNDATION_LIB PocoFoundation PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_UTIL_LIB PocoUtil PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_NET_SSL_LIB PocoNetSSL PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_DATA_LIB PocoData PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_JSON_LIB PocoJSON PATHS ${BUILD_LIB_PATH} REQUIRED)
+ find_library(POCO_NET_LIB PocoNet PATHS ${BUILD_LIB_PATH} REQUIRED)
+ message("use Poco Release libs")
+ENDIF()
+
+set(POCO_LIBS ${POCO_FOUNDATION_LIB} ${POCO_UTIL_LIB} ${POCO_NET_SSL_LIB} ${POCO_DATA_LIB} ${POCO_JSON_LIB} ${POCO_NET_LIB})
+
+
+############################## build login server ###################################
+
+target_link_libraries(Gradido_LoginServer gRPC::grpc++ ${PROTOBUF_LIBS} ${MYSQL_LIBRARIES} ${POCO_LIBS} sodium pthread)
+
diff --git a/login_server/Dockerfile b/login_server/Dockerfile
index e6c2d6b89..bc3cb9807 100644
--- a/login_server/Dockerfile
+++ b/login_server/Dockerfile
@@ -1,50 +1,45 @@
#########################################################################################################
# Build release
#########################################################################################################
-From conanio/gcc9 as release
+FROM gradido/login_dependencies:alpine-release-1 as release
ENV DOCKER_WORKDIR="/code"
-
-USER root
-
-
-RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
-COPY . .
-
-RUN cd dependencies/mariadb-connector-c && \
- mkdir build && \
- cd build && \
- cmake -DWITH_SSL=OFF ..
-
-RUN chmod +x compile_pot.sh && ./compile_pot.sh
-
+COPY ./CMakeLists.txt.lib ./CMakeLists.txt
+COPY ./src ./src
+COPY ./dependencies/cmake-modules ./dependencies/cmake-modules
+COPY ./dependencies/spirit-po ./dependencies/spirit-po
+COPY ./dependencies/tinf ./dependencies/tinf
+COPY ./scripts ./scripts
+RUN cd scripts && \
+ chmod +x compile_pot.sh && \
+ ./compile_pot.sh
+
RUN mkdir build && \
cd build && \
- conan install .. --build=missing && \
- cmake .. && \
- make -j$(nproc) protoc grpc_cpp_plugin
-
-RUN chmod +x unix_parse_proto.sh && ./unix_parse_proto.sh
+ cmake -DCMAKE_BUILD_TYPE=Release .. && \
+ make -j$(nproc) Gradido_LoginServer
-RUN cd build && \
- cmake .. && \
- make -j$(nproc) Gradido_LoginServer
-
-CMD ["./code"]
#########################################################################################################
# run release
#########################################################################################################
#From alpine:latest as login_server
-FROM alpine:latest as login_server
+FROM alpine:3.13.5 as login_server
+USER root
WORKDIR "/usr/bin"
COPY --from=release /code/build/bin/Gradido_LoginServer /usr/bin/
-COPY --from=release /code/build/lib/libmariadb.so.3 /usr/lib/
+
+COPY --from=release /usr/local/lib/mariadb/libmariadb.so.3 /usr/local/lib/
+COPY --from=release /usr/local/lib/libPoco* /usr/local/lib/
+COPY --from=release /usr/lib/libsodium.so.23 /usr/lib/
+COPY --from=release /usr/lib/libstdc++.so.6 /usr/lib/
+COPY --from=release /usr/lib/libgcc_s.so.1 /usr/lib/
+
RUN chmod +x /usr/bin/Gradido_LoginServer
ENTRYPOINT ["/usr/bin/Gradido_LoginServer"]
-CMD Gradido_LoginServer
+#CMD Gradido_LoginServer
diff --git a/login_server/Dockerfile.alpine-debug b/login_server/Dockerfile.alpine-debug
new file mode 100644
index 000000000..948d434d1
--- /dev/null
+++ b/login_server/Dockerfile.alpine-debug
@@ -0,0 +1,14 @@
+FROM gradido/login_dependencies:alpine-debug-1 as login_server_alpine_debug
+
+ENV DOCKER_WORKDIR="/code"
+
+
+EXPOSE 1200
+EXPOSE 1201
+WORKDIR ${DOCKER_WORKDIR}
+
+COPY ./CMakeLists.txt.lib ./CMakeLists.txt
+COPY ./scripts ./scripts
+
+CMD cd scripts; ./build_debug.sh; cd ..; ./build/bin/Gradido_LoginServer
+
diff --git a/login_server/Dockerfile.debug b/login_server/Dockerfile.debug
index f1b235e4e..613c3daf4 100644
--- a/login_server/Dockerfile.debug
+++ b/login_server/Dockerfile.debug
@@ -1,3 +1,19 @@
+#########################################################################################################
+# cmake
+#########################################################################################################
+FROM gcc:9 as cmake-gcc-9
+
+ENV DOCKER_WORKDIR="/code"
+RUN mkdir -p ${DOCKER_WORKDIR}
+WORKDIR ${DOCKER_WORKDIR}
+
+USER root
+
+RUN git clone https://github.com/Kitware/CMake.git --branch=v3.19.8 \
+ && cd CMake \
+ && ./bootstrap \
+ && make -j$(nproc) \
+ && make install
#########################################################################################################
# Build debug
@@ -5,14 +21,15 @@
From gradido/login_dependencies:stage2 as debug
ENV DOCKER_WORKDIR="/code"
-
+
USER root
WORKDIR ${DOCKER_WORKDIR}
-COPY . .
+COPY . .
-RUN chmod +x unix_parse_proto.sh
-RUN chmod +x compile_pot.sh
+RUN cd scripts \
+ && chmod +x ./prepare_build.sh \
+ && ./prepare_build.sh
RUN ./compile_pot.sh
RUN ./unix_parse_proto.sh
@@ -30,13 +47,14 @@ ENV DOCKER_WORKDIR="/code"
# apt-get autoremove && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*
-
+
VOLUME /var/log/grd_login
VOLUME /code/src
EXPOSE 1200
EXPOSE 1201
WORKDIR ${DOCKER_WORKDIR}
-RUN chmod +x ./Dockerfiles/build_and_run.sh
+RUN chmod +x ./scripts/build_and_run.sh
CMD ./Dockerfiles/build_and_run.sh; ./build_vol/bin/Gradido_LoginServer
+
diff --git a/login_server/Dockerfiles/Dockerfile.dependencies b/login_server/Dockerfiles/Dockerfile.dependencies
index 0194c7c82..79a573ea2 100644
--- a/login_server/Dockerfiles/Dockerfile.dependencies
+++ b/login_server/Dockerfiles/Dockerfile.dependencies
@@ -1,56 +1,93 @@
#########################################################################################################
-# debug build preparation
+# gcc 9 with libssl
#########################################################################################################
-From conanio/gcc9 as build_debug_preparation
+FROM gcc:9 as gcc_9_libssl
USER root
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends libssl-dev libboost-dev && \
+ apt-get autoclean && \
+ apt-get autoremove && \
+ apt-get clean && \
+ rm -rf /var/lib/apt/lists/*
+
+
+#########################################################################################################
+# gcc 9 cmake
+#########################################################################################################
+FROM gcc_9_libssl as gcc_9_cmake
+
+USER root
ENV DOCKER_WORKDIR="/code"
-
+
RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
+
+RUN git clone https://github.com/Kitware/CMake.git --branch=v3.19.8 && \
+ cd CMake && \
+ ./bootstrap --parallel=$(nproc) && \
+ make -j$(nproc) && \
+ make install && \
+ cd .. && \
+ rm -rf CMake
+
+#########################################################################################################
+# debug build preparation
+#########################################################################################################
+FROM gcc_9_libssl as build_debug_dependencies
+
+USER root
+ENV DOCKER_WORKDIR="/code"
+
+RUN mkdir -p ${DOCKER_WORKDIR}
+WORKDIR ${DOCKER_WORKDIR}
+
+# copy CMake from last stage
+COPY --from=gcc_9_cmake /usr/local/bin/cmake /usr/local/bin/cmake
+COPY --from=gcc_9_cmake /usr/local/share/cmake-3.19/Modules /usr/local/share/cmake-3.19/Modules
+COPY --from=gcc_9_cmake /usr/local/share/cmake-3.19/Templates /usr/local/share/cmake-3.19/Templates
+
COPY ./dependencies ./dependencies
-COPY ./conanfile.txt ./conanfile.txt
-
-
-RUN cd dependencies/mariadb-connector-c && \
- mkdir build && \
- cd build && \
- cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_SSL=OFF ..
-
-
-RUN mkdir build && \
- cd build && \
- conan install .. --build=missing -s build_type=Debug
-
-
-#########################################################################################################
-# debug build proto and grpc
-#########################################################################################################
-From build_debug_preparation as proto_grpc
-
-ENV DOCKER_WORKDIR="/code"
-WORKDIR ${DOCKER_WORKDIR}
-
+COPY ./scripts ./scripts
COPY ./CMakeLists.txt .
-RUN cd build && \
- cmake -DCMAKE_BUILD_TYPE=Debug .. && \
- make -j${CPU_COUNT} protoc grpc_cpp_plugin
+COPY ./src ./src
+
+
+RUN cd scripts && \
+ chmod +x ./prepare_build.sh && \
+ ./prepare_build.sh && \
+ mkdir ../build && \
+ chmod +x ./build_debug.sh && \
+ ./build_debug.sh
+
+# remove unneccessary stuff
+RUN rm -rf build/bin/Gradido_LoginServer
#########################################################################################################
-# parse proto and gettext
+# debug build
#########################################################################################################
-From proto_grpc as proto_parse
+FROM gcc_9_libssl as build_debug
+USER root
ENV DOCKER_WORKDIR="/code"
+
+RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
-RUN mkdir src && \
- cd src && \
- mkdir cpp
-COPY ./src/proto ./src/proto
-COPY ./unix_parse_proto.sh .
-RUN chmod +x unix_parse_proto.sh && \
- ./unix_parse_proto.sh
-
+# copy CMake from last stage
+COPY --from=build_debug_dependencies /usr/local/bin/cmake /usr/local/bin/cmake
+COPY --from=build_debug_dependencies /usr/local/share/cmake-3.19 /usr/local/share/cmake-3.19
+
+COPY --from=build_debug_dependencies /code/build/bin /code/build/bin
+COPY --from=build_debug_dependencies /code/build/lib /code/build/lib
+
+# grpc
+COPY --from=build_debug_dependencies /code/build/dependencies/grpc/lib /build/dependencies/grpc/lib
+COPY --from=build_debug_dependencies /code/build/dependencies/grpc/third_party/protobuf/lib /build/dependencies/grpc/third_party/protobuf/lib
+COPY --from=build_debug_dependencies /code/build/dependencies/grpc/third_party/re2/lib /build/dependencies/grpc/third_party/re2/lib
+COPY --from=build_debug_dependencies /code/build/dependencies/grpc/third_party/zlib/lib /build/dependencies/grpc/third_party/zlib/lib
+COPY --from=build_debug_dependencies /code/build/dependencies/grpc/third_party/cares/cares/lib /build/dependencies/grpc/third_party/cares/cares/lib
+COPY --from=build_debug_dependencies /code/build/dependencies/mariadb-connector-c/libmariadb/lib /build/dependencies/mariadb-connector-c/libmariadb/lib
+
diff --git a/login_server/Dockerfiles/Dockerfile.dependencies-alpine b/login_server/Dockerfiles/Dockerfile.dependencies-alpine
new file mode 100644
index 000000000..a2cc3225c
--- /dev/null
+++ b/login_server/Dockerfiles/Dockerfile.dependencies-alpine
@@ -0,0 +1,79 @@
+
+##### BUILD-ENV #####
+FROM alpine:3.13.5 as alpine-build
+
+RUN apk add --update --no-cache icu-dev
+RUN apk add --no-cache git openssl-dev make gcc musl-dev g++ linux-headers libintl gettext-dev boost-dev libsodium-dev
+
+
+##### CMAKE #####
+FROM alpine-build as alpine-gxx-cmake
+
+RUN git clone https://github.com/Kitware/CMake.git --branch=v3.19.8 && \
+ cd CMake && \
+ ./bootstrap --parallel=$(nproc) && \
+ make -j$(nproc) && \
+ make install
+
+######### BUILD grpc ##############
+FROM alpine-gxx-cmake as alpine-gxx-grpc
+
+ARG BUILD_TYPE=Debug
+
+RUN git clone https://github.com/grpc/grpc.git --branch=v1.37.0 --recursive -j4 && \
+ cd grpc && \
+ mkdir build && cd build && \
+ cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && make -j$(nproc) && \
+ make install
+
+# abseil don't install themself correctly
+RUN cp -r grpc/third_party/abseil-cpp/absl /usr/local/include/
+
+# protobuf libs missing after make install
+RUN cp grpc/build/third_party/protobuf/*.a /usr/local/lib/
+
+######### BUILD poco ##############
+FROM alpine-gxx-cmake as alpine-gxx-poco
+
+ARG BUILD_TYPE=Debug
+
+RUN git clone https://github.com/pocoproject/poco.git --recursive && \
+ cd poco && \
+ git checkout poco-1.9.4-release && \
+ mkdir cmake-build && cd cmake-build && \
+ cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && make -j$(nproc) && \
+ make install
+
+######### BUILD mariadb ###########
+FROM alpine-gxx-cmake as alpine-gxx-mariadb-connector
+
+ARG BUILD_TYPE=Debug
+
+RUN git clone https://github.com/mariadb-corporation/mariadb-connector-c.git && \
+ cd mariadb-connector-c && \
+ git checkout 159540f && \
+ mkdir build && cd build && \
+ cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && make -j$(nproc) && \
+ make install
+
+#########################################################################################################
+# builded libs and binaries
+#########################################################################################################
+FROM alpine-build as alpine-libs
+
+# copy CMake from cmake stage
+COPY --from=alpine-gxx-cmake /usr/local/bin/cmake /usr/local/bin/cmake
+COPY --from=alpine-gxx-cmake /usr/local/share/cmake-3.19/Modules /usr/local/share/cmake-3.19/Modules
+COPY --from=alpine-gxx-cmake /usr/local/share/cmake-3.19/Templates /usr/local/share/cmake-3.19/Templates
+
+# copy from grpc
+COPY --from=alpine-gxx-grpc /usr/local /usr/local
+
+
+# COPY from poco
+COPY --from=alpine-gxx-poco /usr/local /usr/local
+
+# COPY from mariadb
+COPY --from=alpine-gxx-mariadb-connector /usr/local /usr/local
+
+
diff --git a/login_server/Dockerfiles/build_and_run.sh b/login_server/Dockerfiles/build_and_run.sh
deleted file mode 100644
index fa3e95859..000000000
--- a/login_server/Dockerfiles/build_and_run.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-cp build/conan* build_vol/
-
-cd build_vol
-cmake -DCMAKE_BUILD_TYPE=Debug ..
-make -j${CPU_COUNT} protoc grpc_cpp_plugin
-
-cd ..
-if [ ! -f "./src/cpp/proto/gradido/TransactionBody.pb.h" ] ; then
- chmod +x unix_parse_proto.sh
- echo "parse proto files"
- ./unix_parse_proto.sh
-fi
-chmod +x compile_pot.sh
-./compile_pot.sh
-
-cd build_vol
-cmake ..
-make -j$(nproc) Gradido_LoginServer
-#echo "building done"
-chmod +x ./bin/Gradido_LoginServer
-#./bin/Gradido_LoginServer
-
-
-: '
-cd build
-conan install .. --build=missing -s build_type=Debug
-cmake -DCMAKE_BUILD_TYPE=Debug ..
-make -j${CPU_COUNT} protoc grpc_cpp_plugin
-cd ..
-
-if [ ! -d "./src/cpp/proto/hedera" ] ; then
-#if [ ! -f "./src/cpp/proto/gradido/TransactionBody.pb.h"] ; then
- chmod +x unix_parse_proto.sh
- ./unix_parse_proto.sh
-fi
-chmod +x compile_pot.sh
-
-./compile_pot.sh
-
-cd build
-cmake -DCMAKE_BUILD_TYPE=Debug ..
-make -j$(nproc) Gradido_LoginServer
-#echo "building done"
-chmod +x ./bin/Gradido_LoginServer
-#./bin/Gradido_LoginServer
-'
diff --git a/login_server/README b/login_server/README
index 85f15134c..400aee30a 100644
--- a/login_server/README
+++ b/login_server/README
@@ -1,3 +1,5 @@
+sudo apt install libsodium-dev
+
# get dependencies
git submodule update --init --recursive
diff --git a/login_server/compile_pot.sh b/login_server/compile_pot.sh
deleted file mode 100755
index df6f5e435..000000000
--- a/login_server/compile_pot.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-xgettext -D src/cpp -p src/LOCALE -o messages.pot --from-code=UTF-8 --files-from=files_to_translate.txt
diff --git a/login_server/conanfile.txt b/login_server/conanfile.txt
index ae0fcd97b..5d3dd4ebb 100644
--- a/login_server/conanfile.txt
+++ b/login_server/conanfile.txt
@@ -2,12 +2,7 @@
Poco/1.9.4@pocoproject/stable
libsodium/1.0.18@bincrafters/stable
boost/1.71.0@conan/stable
-gtest/1.8.1@bincrafters/stable
+
[generators]
cmake
-
-[options]
-Poco:enable_data_sqlite=False
-Poco:enable_mongodb=False
-Poco:enable_redis=False
diff --git a/login_server/dependencies/libsodium b/login_server/dependencies/libsodium
new file mode 160000
index 000000000..8aedf4733
--- /dev/null
+++ b/login_server/dependencies/libsodium
@@ -0,0 +1 @@
+Subproject commit 8aedf4733884a25434b5c17c79c7e7dee27e6eb0
diff --git a/login_server/dependencies/poco b/login_server/dependencies/poco
index 3fc3e5f5b..b95393dcc 160000
--- a/login_server/dependencies/poco
+++ b/login_server/dependencies/poco
@@ -1 +1 @@
-Subproject commit 3fc3e5f5b8462f7666952b43381383a79b8b5d92
+Subproject commit b95393dcc3640807838e8323b4e600e54d2e8116
diff --git a/login_server/parse_proto.sh b/login_server/parse_proto.sh
deleted file mode 100644
index 1ec7c106e..000000000
--- a/login_server/parse_proto.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-if [ ! -d "./src/cpp/proto" ] ; then
- mkdir ./src/cpp/proto
-fi
-if [ ! -d "./src/cpp/proto/gradido" ] ; then
- mkdir ./src/cpp/proto/gradido
-fi
-
-./protoc --cpp_out=./src/cpp/proto --proto_path=./src/proto ./src/proto/gradido/*.proto
-
-if [ ! -d "./src/cpp/proto/hedera" ] ; then
- mkdir ./src/cpp/proto/hedera
-fi
-
-
-./protoc --plugin=protoc-gen-grpc=./grpc_cpp_plugin.exe --cpp_out=./src/cpp/proto/hedera --grpc_out=./src/cpp/proto/hedera --proto_path=./src/proto/hedera/hedera-protobuf/src/main/proto ./src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
diff --git a/login_server/scripts/build_debug.sh b/login_server/scripts/build_debug.sh
new file mode 100755
index 000000000..84356018e
--- /dev/null
+++ b/login_server/scripts/build_debug.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+cd ../scripts
+
+chmod +x compile_pot.sh
+./compile_pot.sh
+
+cd ../build
+cmake -DCMAKE_BUILD_TYPE=Debug ..
+make -j$(nproc) Gradido_LoginServer
+
+chmod +x ./bin/Gradido_LoginServer
diff --git a/login_server/scripts/compile_pot.sh b/login_server/scripts/compile_pot.sh
new file mode 100755
index 000000000..1d817be55
--- /dev/null
+++ b/login_server/scripts/compile_pot.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+xgettext -D ../src/cpp -p ../src/LOCALE -o messages.pot --from-code=UTF-8 --files-from=files_to_translate.txt
diff --git a/login_server/files_to_translate.txt b/login_server/scripts/files_to_translate.txt
similarity index 75%
rename from login_server/files_to_translate.txt
rename to login_server/scripts/files_to_translate.txt
index 96fbfa8b6..9bc694e1e 100644
--- a/login_server/files_to_translate.txt
+++ b/login_server/scripts/files_to_translate.txt
@@ -6,4 +6,5 @@ model/Session.cpp
model/email/Email.cpp
model/email/EmailCustomReply.cpp
model/email/EmailNotificationCreation.cpp
-model/email/EmailNotificationTransfer.cpp
\ No newline at end of file
+model/email/EmailNotificationTransfer.cpp
+SingletonManager/SessionManager.cpp
\ No newline at end of file
diff --git a/login_server/scripts/prepare_build.sh b/login_server/scripts/prepare_build.sh
new file mode 100755
index 000000000..8706e4139
--- /dev/null
+++ b/login_server/scripts/prepare_build.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# generate version for mariadb connector
+
+cd ../dependencies/mariadb-connector-c
+if [ -d "./build" ] ; then
+ rm -rf ./build
+fi
+mkdir build
+cd build
+cmake -DWITH_SSL=OFF ..
+cd ../../
+
+
+
diff --git a/login_server/scripts/unix_parse_proto.sh b/login_server/scripts/unix_parse_proto.sh
new file mode 100755
index 000000000..5f8a86023
--- /dev/null
+++ b/login_server/scripts/unix_parse_proto.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+if [ ! -d "../src/cpp/proto" ] ; then
+ mkdir ../src/cpp/proto
+fi
+if [ ! -d "../src/cpp/proto/gradido" ] ; then
+ mkdir ../src/cpp/proto/gradido
+fi
+PROTOC_PATH=../build/bin
+CPP_PLUGIN_PATH=../build/bin
+$PROTOC_PATH/protoc --cpp_out=../src/cpp/proto --proto_path=../src/proto ../src/proto/gradido/*.proto
+
+if [ ! -d "../src/cpp/proto/hedera" ] ; then
+ mkdir ../src/cpp/proto/hedera
+fi
+
+GOOGLE_PROTOBUF_INCLUDES=../dependencies/grpc/third_party/protobuf/src
+$PROTOC_PATH/protoc --plugin=protoc-gen-grpc=$CPP_PLUGIN_PATH/grpc_cpp_plugin --cpp_out=../src/cpp/proto/hedera --grpc_out=../src/cpp/proto/hedera --proto_path=$GOOGLE_PROTOBUF_INCLUDES --proto_path=../src/proto/hedera/hedera-protobuf/src/main/proto ../src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
+
+
diff --git a/login_server/scripts/windows_parse_proto.sh b/login_server/scripts/windows_parse_proto.sh
new file mode 100644
index 000000000..b01ae74d7
--- /dev/null
+++ b/login_server/scripts/windows_parse_proto.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+if [ ! -d "../src/cpp/proto" ] ; then
+ mkdir ../src/cpp/proto
+fi
+if [ ! -d "../src/cpp/proto/gradido" ] ; then
+ mkdir ../src/cpp/proto/gradido
+fi
+PROTOC_PATH=build/bin
+CPP_PLUGIN_PATH=build/bin
+$PROTOC_PATH/protoc.exe --cpp_out=../src/cpp/proto --proto_path=../src/proto ../src/proto/gradido/*.proto
+
+if [ ! -d "./src/cpp/proto/hedera" ] ; then
+ mkdir ./src/cpp/proto/hedera
+fi
+
+GOOGLE_PROTOBUF_INCLUDES=../dependencies/grpc/third_party/protobuf/src
+$PROTOC_PATH/protoc.exe --plugin=protoc-gen-grpc=$CPP_PLUGIN_PATH/grpc_cpp_plugin.exe --cpp_out=../src/cpp/proto/hedera --grpc_out=../src/cpp/proto/hedera --proto_path=$GOOGLE_PROTOBUF_INCLUDES --proto_path=../src/proto/hedera/hedera-protobuf/src/main/proto ../src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
+
+
diff --git a/login_server/src/LOCALE/de_DE.mo b/login_server/src/LOCALE/de_DE.mo
index 3ab456b2d..a38486518 100644
Binary files a/login_server/src/LOCALE/de_DE.mo and b/login_server/src/LOCALE/de_DE.mo differ
diff --git a/login_server/src/LOCALE/de_DE.po b/login_server/src/LOCALE/de_DE.po
index 18fa4262e..8691eff55 100644
--- a/login_server/src/LOCALE/de_DE.po
+++ b/login_server/src/LOCALE/de_DE.po
@@ -7,184 +7,187 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-05-28 10:50+0200\n"
-"PO-Revision-Date: 2020-05-28 10:54+0200\n"
+"POT-Creation-Date: 2021-05-18 12:17+0200\n"
+"PO-Revision-Date: 2021-05-18 12:21+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 2.3.1\n"
+"X-Generator: Poedit 2.4.3\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:85
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:124
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:181
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:260
msgid "Login"
msgstr "Anmeldung"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:85
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:181
msgid "E-Mail or password isn't right, please try again!"
msgstr ""
"E-Mail und Passwort Kombination stimmen nicht, bitte versuche es erneut. "
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:88
-#, fuzzy
-#| msgid "Password"
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:190
msgid "Passwort"
msgstr "Passwort"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:88
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:190
msgid ""
"Passwort wird noch berechnet, bitte versuche es in etwa 1 Minute erneut."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:91
-msgid "Account"
-msgstr "Konto"
-
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:91
-msgid "E-Mail Address not checked, do you already get one?"
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:193
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:196
+msgid "User"
msgstr ""
-"E-Mail Adresse wurde noch nicht überprüft. Hast du schon in deine E-Mails "
-"geschaut? Bitte schau auch in dein Spam-Verzeichnis nach."
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:124
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:193
+msgid "Error in saved data, the server admin will look at it."
+msgstr ""
+
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:196
+msgid "Benutzer ist deaktiviert, kein Login möglich!"
+msgstr ""
+
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:260
msgid "Username and password are needed!"
msgstr "E-Mail und Passwort werden benötigt!"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:175
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:50
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:54
-#: model/Session.cpp:163 model/Session.cpp:170 model/Session.cpp:209
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:290
+#: model/Session.cpp:164 model/Session.cpp:171 model/Session.cpp:223
#: model/Session.cpp:234
msgid "E-Mail"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:178
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:291
+#: SingletonManager/SessionManager.cpp:608
+#: SingletonManager/SessionManager.cpp:614
+#: SingletonManager/SessionManager.cpp:620
+#: SingletonManager/SessionManager.cpp:626
+#: SingletonManager/SessionManager.cpp:632
+#: SingletonManager/SessionManager.cpp:638
msgid "Password"
msgstr "Passwort"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:180
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:292
msgid " Login "
msgstr "Anmeldung"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:182
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:297
msgid "You haven't any account yet? Please follow the link to create one."
msgstr "Du hast noch kein Gradido-Konto?"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:183
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:299
msgid "Create New Account"
msgstr "Neues Konto erstellen"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp:186
+#: F:\\Gradido\\gradido_stage2_local\\login_server\\src\\cpsp\\login.cpsp:303
msgid "Passwort vergessen"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:97
-msgid "Bitte gebe deinen E-Mail Verification Code ein:"
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:73
+msgid "E-Mail verifizieren"
+msgstr "E-Mail überprüfen"
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:78
+msgid ""
+"Deine E-Mail wurde erfolgreich bestätigt. Du kannst nun Gradidos versenden."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:98
-#: model/Session.cpp:186
-#, fuzzy
-#| msgid "E-Mail Verification"
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:79
+msgid "Zur Startseite"
+msgstr ""
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:81
+msgid "Bitte gib deinen E-Mail Verification Code ein:"
+msgstr "Bitte gib deinen E-Mail Verification Code ein:"
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:82
+#: model/Session.cpp:187
msgid "Email Verification Code"
-msgstr "E-Mail Überprüfung"
+msgstr "Email Verification Code"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:100
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:83
msgid "Überprüfe Code"
-msgstr ""
+msgstr "Überprüfe Code"
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:104
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:86
msgid "Du hast bisher keinen Code erhalten?"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:105
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:87
msgid "E-Mail erneut zuschicken (in Arbeit)"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:108
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:90
msgid "Funktioniert dein E-Mail Verification Code nicht?"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:109
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:91
msgid "Schicke uns eine E-Mail und wir kümmern uns darum: "
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:110
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:133
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkEmail.cpsp:92
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:151
msgid "E-Mail an Support schicken"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:50
-msgid "E-Mail Adresse konnte nicht gefunden werden oder ist nicht aktiviert."
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:113
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:124
+msgid "Gib bitte hier deine E-Mail Adresse an:"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:54
-msgid "E-Mail Adresse nicht angegeben."
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:116
+msgid "Bestätigen"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:59
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:74
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:26
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:94
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:114
-#: model/Session.cpp:495 model/Session.cpp:507 model/Session.cpp:515
-msgid "Passphrase"
-msgstr ""
-
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:59
-msgid "Bitte wähle eine Option aus."
-msgstr ""
-
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:74
-msgid "Ungültige Option"
-msgstr ""
-
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:107
-msgid "Gebe bitte hier deine E-Mail Adresse an:"
-msgstr ""
-
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:109
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:126
msgid "Hast du dir deine Passphrase notiert oder gemerkt?"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:113
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:196
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:131
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:206
msgid "Ja"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:118
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:136
msgid "Nein"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:123
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:140
msgid "Absenden"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:127
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:145
msgid "Dir wird eine E-Mail zugeschickt um dein Passwort zurückzusetzen."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:129
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:147
msgid "Der Admin hat eine E-Mail bekommen und wird sich bei dir melden."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:131
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:149
msgid ""
"Du hast bereits eine E-Mail bekommen. Bitte schau auch in dein Spam-"
"Verzeichnis nach. "
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp:132
+#: F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp:150
msgid ""
"Du hast wirklich keine E-Mail erhalten und auch schon ein paar Minuten "
"gewartet?"
msgstr ""
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:26
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:96
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:117
+#: model/Session.cpp:468 model/Session.cpp:480 model/Session.cpp:494
+msgid "Passphrase"
+msgstr ""
+
#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:27
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:256
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:266
msgid "Neues Konto anlegen"
msgstr ""
@@ -192,222 +195,304 @@ msgstr ""
msgid "2/3"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:94
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:96
msgid ""
"Diese Passphrase ist ungültig, bitte überprüfen oder neu "
"generieren (lassen)."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:114
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:117
msgid "intern error please try again later"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:129
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:132
msgid "3/3"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:132
#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:135
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:138
msgid "1/3"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:134
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:137
msgid "Neues Passwort anlegen"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:153
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:188
-msgid "Was zu tun ist:"
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:148
+msgid "Passphrase abschreiben"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:154
-msgid ""
-"Schreibe dir deine Passphrase auf und packe sie gut weg. Du brauchst sie um "
-"deine Adresse wiederherzustellen. Wenn du sie verlierst, sind auch deine "
-"Gradidos verloren."
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:159
+msgid "Was ist eine Passphrase?"
msgstr ""
-"Schreibe dir deine Passphrase auf oder drucke sie aus und bewahre sie
in "
-"Papier-Form an einem sicheren Ort auf (speichere sie nicht auf deinem "
-"Rechner oder Mobilgerät)! Du brauchst deine Passphrase um dein Konto "
-"wiederherzustellen, wenn du mal dein Passort vergessen haben solltest. "
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:157
-msgid "Deine Passphrase (Groß/Kleinschreibung beachten)"
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:160
+msgid "Deine Passphrase besteht aus den im grünen Feld angezeigten Wörtern."
msgstr ""
#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:161
-msgid "Was ist eine Passphrase?"
+msgid "Sie dient deiner Sicherheit."
msgstr ""
#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:162
msgid ""
-"Die Passphrase kommt aus dem Crypto-Bereich und ist ein Weg einen "
-"komplizierte kryptografischen Schlüssel in einer lesbaren Form darzustellen."
+"Du brauchst deine Passphrase um dein Konto wiederherzustellen, wenn du mal "
+"dein Passwort vergessen haben solltest."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:163
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:164
+msgid "Deine Passphrase (Groß/Kleinschreibung beachten)"
+msgstr ""
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:169
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:197
+msgid "Was zu tun ist:"
+msgstr ""
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:170
msgid ""
-"Der neue Gradido basiert technisch auf einer Kryptowährung (wie z.B. "
-"Bitcoin) um maximale Sicherheit zu erreichen."
+"Schreibe dir die obenstehende Passphrase
von Hand auf ein Blatt "
+"Papier!"
msgstr ""
-"Der neue Gradido basiert technisch auf einer Kryptowährung (wie z.B. "
-"Bitcoin) um für dich die maximale Sicherheit zu gewährleisten."
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:165
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:275
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:280
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:293
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:171
+msgid "Speichere sie auf keinen Fall auf deinem Rechner oder Mobilgerät!!"
+msgstr ""
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:172
+msgid "Bewahre sie an einem sicheren Ort auf!"
+msgstr ""
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:174
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:285
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:290
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:303
msgid "Weiter"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:189
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:198
msgid "Hast du dir deine Passphrase gemerkt?"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:190
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:199
msgid ""
"Dann zeig es mir. Zur Unterstützung gebe ich dir deine Wörter aber in "
"anderer Reihenfolge."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:191
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:200
msgid "Klicke sie an um sie einzusetzen."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:195
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:201
+msgid "Überprüfe dabei, ob du alle Wörter richtig geschrieben hast!"
+msgstr ""
+
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:205
msgid ""
"Weil du kein Javascript verwendest geht es direkt weiter. Hast du dir deine "
"Passphrase gemerkt oder aufgeschrieben?"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:242
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:252
msgid "Deine E-Mail Adresse wurde erfolgreich bestätigt."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:246
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:256
msgid "Neue Gradido Adresse anlegen / wiederherstellen"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:247
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:257
msgid ""
"Möchtest du ein neues Gradido-Konto anlegen oder ein bestehendes "
"wiederherstellen?"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:263
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:273
msgid "Bestehendes Konto wiederherstellen"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:270
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:280
msgid ""
"Falls du ein bestehendes Konto wiederherstellen willst, gib hier deine "
"Passphrase ein:"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:288
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:297
msgid "Konto wiederherstellen / Neues Passwort anlegen"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:289
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:299
msgid ""
-"Um dein Konto wiederherzustellen, dir ein Neues Passwort auswählen zu "
+"Um dein Konto wiederherzustellen und dir ein Neues Passwort auswählen zu "
"können, tippe hier bitte die Wörter deiner Passphrase in der richtigen "
"Reihenfolge ein, welche du dir aufgeschrieben hast."
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:303
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:313
msgid "Fehler"
msgstr ""
-#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:304
+#: F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp:314
msgid ""
"Ungültige Seite, wenn du das siehst stimmt hier etwas nicht. Bitte wende "
"dich an den Server-Admin."
msgstr ""
-#: model/Session.cpp:149 model/Session.cpp:180 model/Session.cpp:700
-#: model/Session.cpp:706 model/Session.cpp:1005
+#: model/Session.cpp:150 model/Session.cpp:180 model/Session.cpp:779
+#: model/Session.cpp:785 model/Session.cpp:1061 model/Session.cpp:1077
msgid "Benutzer"
msgstr ""
-#: model/Session.cpp:149
+#: model/Session.cpp:150
msgid "Eingeloggter Benutzer ist kein Admin"
msgstr ""
-#: model/Session.cpp:155 model/Session.cpp:201
+#: model/Session.cpp:156 model/Session.cpp:215
msgid "Vorname"
msgstr ""
-#: model/Session.cpp:155 model/Session.cpp:159 model/Session.cpp:201
-#: model/Session.cpp:205
+#: model/Session.cpp:156 model/Session.cpp:160 model/Session.cpp:215
+#: model/Session.cpp:219
msgid ""
"Bitte gebe einen Namen an. Mindestens 3 Zeichen, keines folgender Zeichen "
"<>&;"
msgstr ""
-#: model/Session.cpp:159 model/Session.cpp:205
+#: model/Session.cpp:160 model/Session.cpp:219
msgid "Nachname"
msgstr ""
-#: model/Session.cpp:163 model/Session.cpp:209
+#: model/Session.cpp:164 model/Session.cpp:223
msgid "Bitte gebe eine gültige E-Mail Adresse an."
msgstr ""
-#: model/Session.cpp:170 model/Session.cpp:234
+#: model/Session.cpp:171
msgid "Für diese E-Mail Adresse gibt es bereits einen Account"
msgstr ""
-#: model/Session.cpp:180 model/Session.cpp:186
+#: model/Session.cpp:180 model/Session.cpp:187
msgid "Fehler beim speichern!"
msgstr ""
-#: model/Session.cpp:379 model/Session.cpp:438 model/Session.cpp:881
-#: model/Session.cpp:889
+#: model/Session.cpp:234
+msgid "Für diese E-Mail Adresse gibt es bereits ein Konto"
+msgstr ""
+
+#: model/Session.cpp:258
+msgid "Server"
+msgstr ""
+
+#: model/Session.cpp:258
+msgid "Fehler beim speichen des Kontos bitte versuche es später noch einmal"
+msgstr ""
+
+#: model/Session.cpp:353 model/Session.cpp:393 model/Session.cpp:966
+#: model/Session.cpp:975
msgid "E-Mail Verification"
msgstr "E-Mail Überprüfung"
-#: model/Session.cpp:379
+#: model/Session.cpp:353
msgid "Du hast dein Konto bereits aktiviert!"
msgstr ""
-#: model/Session.cpp:438
+#: model/Session.cpp:393
msgid "Falscher Code für aktiven Login"
msgstr ""
-#: model/Session.cpp:495
+#: model/Session.cpp:468
msgid "Deine Passphrase ist ungütig"
msgstr ""
-#: model/Session.cpp:507
+#: model/Session.cpp:480
msgid "Ein Fehler trat auf, bitte versuche es erneut"
msgstr ""
-#: model/Session.cpp:515
+#: model/Session.cpp:494
msgid "Das ist nicht die richtige Passphrase."
msgstr ""
-#: model/Session.cpp:700
+#: model/Session.cpp:779
msgid "Konnte Community Server nicht erreichen. E-Mail an den Admin ist raus."
msgstr ""
-#: model/Session.cpp:706
+#: model/Session.cpp:785
msgid ""
"Fehler beim Löschen des Accounts. Bitte logge dich erneut ein und "
"versuche es nochmal."
msgstr ""
-#: model/Session.cpp:881
+#: model/Session.cpp:966
msgid "Konnte kein passendes Konto finden."
msgstr ""
-#: model/Session.cpp:889
+#: model/Session.cpp:975
msgid "Fehler beim laden des Benutzers."
msgstr ""
-#: model/Session.cpp:1005
+#: model/Session.cpp:1061
msgid "Kein gültiger Benutzer, bitte logge dich erneut ein."
msgstr ""
+#: model/Session.cpp:1077
+msgid "Fehler beim generieren der Passphrase, der Admin bekommt eine E-Mail. "
+msgstr ""
+
+#: SingletonManager/SessionManager.cpp:609
+msgid ""
+"Please enter a valid password with at least 8 characters, upper and lower "
+"case letters, at least one number and one special character (@$!%*?&+-_)!"
+msgstr ""
+"Bitte gebe ein gültiges Password ein mit mindestens 8 Zeichen, Groß- und "
+"Kleinbuchstaben, mindestens einer Zahl und einem Sonderzeichen (@$!%*?&+-_) "
+"ein!"
+
+#: SingletonManager/SessionManager.cpp:615
+msgid "Your password is to short!"
+msgstr "Dein Passwort ist zu kurz!"
+
+#: SingletonManager/SessionManager.cpp:621
+msgid "Your password does not contain lowercase letters!"
+msgstr "Dein Passwort enthält keine Kleinbuchstaben!"
+
+#: SingletonManager/SessionManager.cpp:627
+msgid "Your password does not contain any capital letters!"
+msgstr " Dein Passwort enthält keine Großbuchstaben!"
+
+#: SingletonManager/SessionManager.cpp:633
+msgid "Your password does not contain any number!"
+msgstr "Dein Passwort enthält keine Zahlen!"
+
+#: SingletonManager/SessionManager.cpp:639
+msgid "Your password does not contain special characters (@$!%*?&+-)!"
+msgstr "Dein Passwort enthält keine Sonderzeichen (@$!%*?&+-)!"
+
+#~ msgid "Account"
+#~ msgstr "Konto"
+
+#~ msgid "E-Mail Address not checked, do you already get one?"
+#~ msgstr ""
+#~ "E-Mail Adresse wurde noch nicht überprüft. Hast du schon in deine E-Mails "
+#~ "geschaut? Bitte schau auch in dein Spam-Verzeichnis nach."
+
+#~ msgid ""
+#~ "Schreibe dir deine Passphrase auf und packe sie gut weg. Du brauchst sie "
+#~ "um deine Adresse wiederherzustellen. Wenn du sie verlierst, sind auch "
+#~ "deine Gradidos verloren."
+#~ msgstr ""
+#~ "Schreibe dir deine Passphrase auf oder drucke sie aus und bewahre sie "
+#~ "
in Papier-Form an einem sicheren Ort auf (speichere sie nicht auf "
+#~ "deinem Rechner oder Mobilgerät)! Du brauchst deine Passphrase um dein "
+#~ "Konto wiederherzustellen, wenn du mal dein Passort vergessen haben "
+#~ "solltest. "
+
+#~ msgid ""
+#~ "Der neue Gradido basiert technisch auf einer Kryptowährung (wie z.B. "
+#~ "Bitcoin) um maximale Sicherheit zu erreichen."
+#~ msgstr ""
+#~ "Der neue Gradido basiert technisch auf einer Kryptowährung (wie z.B. "
+#~ "Bitcoin) um für dich die maximale Sicherheit zu gewährleisten."
+
#~ msgid "Gradido: E-Mail Verification"
#~ msgstr "Gradido: E-Mail Überprüfung"
diff --git a/login_server/src/cpp/Gradido_LoginServer.cpp b/login_server/src/cpp/Gradido_LoginServer.cpp
index c5a9c6076..c3819f951 100644
--- a/login_server/src/cpp/Gradido_LoginServer.cpp
+++ b/login_server/src/cpp/Gradido_LoginServer.cpp
@@ -134,6 +134,9 @@ int Gradido_LoginServer::main(const std::vector
& args)
#if defined(_WIN32) || defined(_WIN64)
log_Path = "./";
#endif
+ if (mConfigPath != "") {
+ log_Path = "./";
+ }
// init speed logger
Poco::AutoPtr speedLogFileChannel(new Poco::SimpleFileChannel(log_Path + "speedLog.txt"));
@@ -165,10 +168,14 @@ int Gradido_LoginServer::main(const std::vector& args)
createConsoleFileAsyncLogger("emailLog", log_Path + "emailLog.txt");
// *************** load from config ********************************************
-
+
std::string cfg_Path = Poco::Path::config() + "grd_login/";
try {
- loadConfiguration(cfg_Path + "grd_login.properties");
+ if(mConfigPath != "") {
+ loadConfiguration(mConfigPath);
+ } else {
+ loadConfiguration(cfg_Path + "grd_login.properties");
+ }
}
catch (Poco::Exception& ex) {
errorLog.error("error loading config: %s", ex.displayText());
@@ -295,4 +302,4 @@ int Gradido_LoginServer::main(const std::vector& args)
}
return Application::EXIT_OK;
-}
\ No newline at end of file
+}
diff --git a/login_server/src/cpp/HTTPInterface/ElopageWebhook.cpp b/login_server/src/cpp/HTTPInterface/ElopageWebhook.cpp
index 67b6fa0d0..af36bcb5a 100644
--- a/login_server/src/cpp/HTTPInterface/ElopageWebhook.cpp
+++ b/login_server/src/cpp/HTTPInterface/ElopageWebhook.cpp
@@ -382,6 +382,7 @@ int HandleElopageRequestTask::run()
DataTypeConverter::strToInt(mRequestData.get("noEmail", "0"), noEMail);
if (noEMail != 1) {
+ emailVerification->setBaseUrl(ServerConfig::g_serverPath + "/checkEmail");
em->addEmail(new model::Email(emailVerification, newUser, model::EMAIL_USER_VERIFICATION_CODE));
}
}
diff --git a/login_server/src/cpp/HTTPInterface/PageRequestHandlerFactory.cpp b/login_server/src/cpp/HTTPInterface/PageRequestHandlerFactory.cpp
index bc1c1148e..e459fd826 100644
--- a/login_server/src/cpp/HTTPInterface/PageRequestHandlerFactory.cpp
+++ b/login_server/src/cpp/HTTPInterface/PageRequestHandlerFactory.cpp
@@ -15,7 +15,7 @@
#include "SaveKeysPage.h"
#include "ElopageWebhook.h"
#include "ElopageWebhookLight.h"
-#include "UpdateUserPasswordPage.h"
+#include "UserUpdatePasswordPage.h"
#include "UserUpdateGroupPage.h"
#include "Error500Page.h"
#include "CheckTransactionPage.h"
@@ -229,7 +229,7 @@ Poco::Net::HTTPRequestHandler* PageRequestHandlerFactory::createRequestHandler(c
auto sessionState = s->getSessionState();
//printf("session state: %s\n", s->getSessionStateString());
if (url_first_part == "/updateUserPassword") {
- return basicSetup(new UpdateUserPasswordPage(s), request, timeUsed);
+ return basicSetup(new UserUpdatePasswordPage(s), request, timeUsed);
}
if (url_first_part == "/checkTransactions") {
return basicSetup(new CheckTransactionPage(s), request, timeUsed);
@@ -318,7 +318,7 @@ Poco::Net::HTTPRequestHandler* PageRequestHandlerFactory::handleCheckEmail(Sessi
assert(session->getNewUser());
if (!session->getNewUser()->hasPassword()) {
// user has no password, maybe account created from elopage webhook
- return basicSetup(new UpdateUserPasswordPage(session), request, timeUsed);
+ return basicSetup(new UserUpdatePasswordPage(session), request, timeUsed);
}
/*
//! \return 1 = konto already exist
@@ -336,7 +336,7 @@ Poco::Net::HTTPRequestHandler* PageRequestHandlerFactory::handleCheckEmail(Sessi
printf("return check email page\n");
pageRequestHandler = new CheckEmailPage(session);
} else if(SESSION_STATE_RESET_PASSWORD_REQUEST == session->getSessionState()) {
- pageRequestHandler = new UpdateUserPasswordPage(session);
+ pageRequestHandler = new UserUpdatePasswordPage(session);
} else {
pageRequestHandler = new PassphrasePage(session);
}
diff --git a/login_server/src/cpp/HTTPInterface/ResetPassword.cpp b/login_server/src/cpp/HTTPInterface/ResetPassword.cpp
index 5b5b95721..0d47ef89e 100644
--- a/login_server/src/cpp/HTTPInterface/ResetPassword.cpp
+++ b/login_server/src/cpp/HTTPInterface/ResetPassword.cpp
@@ -5,7 +5,7 @@
#include "Poco/DeflatingStream.h"
-#line 6 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp"
+#line 6 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp"
#include "../SingletonManager/LanguageManager.h"
#include "../SingletonManager/SessionManager.h"
@@ -20,7 +20,7 @@ enum PageState {
PAGE_WAIT_ADMIN,
PAGE_EMAIL_ALREADY_SEND
};
-#line 1 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 1 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
#include "../ServerConfig.h"
@@ -33,7 +33,7 @@ void ResetPassword::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::N
if (_compressResponse) response.set("Content-Encoding", "gzip");
Poco::Net::HTMLForm form(request, request.stream());
-#line 20 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\resetPassword.cpsp"
+#line 20 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\resetPassword.cpsp"
PageState state = PAGE_EMAIL_ASK;
auto lm = LanguageManager::getInstance();
@@ -95,7 +95,7 @@ void ResetPassword::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::N
// send reset password email
int result = 0;
if(user_exist) {
- result = session->sendResetPasswordEmail(user, sendUserEmail, getBaseUrl());
+ result = session->sendResetPasswordEmail(user, sendUserEmail, ServerConfig::g_serverPath + "/checkEmail");
}
if(2 == result) {
@@ -116,7 +116,7 @@ void ResetPassword::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::N
}
-#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 3 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
bool withMaterialIcons = false;
std::ostream& _responseStream = response.send();
@@ -131,20 +131,20 @@ void ResetPassword::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::N
responseStream << " \n";
responseStream << " \n";
responseStream << "Gradido Login Server: ";
-#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 11 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
responseStream << ( pageName );
responseStream << " \n";
responseStream << " \n";
-#line 13 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 13 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
if(withMaterialIcons) { responseStream << "\n";
responseStream << " \n";
-#line 15 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 15 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
} responseStream << "\n";
responseStream << "\n";
responseStream << "\n";
@@ -152,20 +152,20 @@ void ResetPassword::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::N
responseStream << " \n";
responseStream << " \n";
@@ -345,14 +345,14 @@ void ResetPassword::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::N
responseStream << "
\n";
responseStream << " \n";
responseStream << " ";
-#line 6 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
+#line 6 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\footer.cpsp"
responseStream << ( mTimeProfiler.string() );
responseStream << "\n";
responseStream << "
\n";
responseStream << " \n";
responseStream << "
Login Server in Entwicklung
\n";
responseStream << "
Alpha ";
-#line 10 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
+#line 10 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\footer.cpsp"
responseStream << ( ServerConfig::g_versionString );
responseStream << "
\n";
responseStream << "
\n";
diff --git a/login_server/src/cpp/HTTPInterface/UpdateUserPasswordPage.cpp b/login_server/src/cpp/HTTPInterface/UserUpdatePasswordPage.cpp
similarity index 81%
rename from login_server/src/cpp/HTTPInterface/UpdateUserPasswordPage.cpp
rename to login_server/src/cpp/HTTPInterface/UserUpdatePasswordPage.cpp
index 48a753305..47e3c3d39 100644
--- a/login_server/src/cpp/HTTPInterface/UpdateUserPasswordPage.cpp
+++ b/login_server/src/cpp/HTTPInterface/UserUpdatePasswordPage.cpp
@@ -1,11 +1,11 @@
-#include "UpdateUserPasswordPage.h"
+#include "UserUpdatePasswordPage.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/HTMLForm.h"
#include "Poco/DeflatingStream.h"
-#line 6 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\UpdateUserPassword.cpsp"
+#line 6 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\userUpdatePassword.cpsp"
#include "../SingletonManager/SessionManager.h"
#include "../tasks/AuthenticatedEncryptionCreateKeyTask.h"
@@ -16,18 +16,18 @@ enum PageState {
PAGE_STATE_SUCCEED
};
-#line 1 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 1 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
#include "../ServerConfig.h"
-UpdateUserPasswordPage::UpdateUserPasswordPage(Session* arg):
+UserUpdatePasswordPage::UserUpdatePasswordPage(Session* arg):
SessionHTTPRequestHandler(arg)
{
}
-void UpdateUserPasswordPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
+void UserUpdatePasswordPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
{
response.setChunkedTransferEncoding(true);
response.setContentType("text/html");
@@ -35,12 +35,12 @@ void UpdateUserPasswordPage::handleRequest(Poco::Net::HTTPServerRequest& request
if (_compressResponse) response.set("Content-Encoding", "gzip");
Poco::Net::HTMLForm form(request, request.stream());
-#line 17 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\UpdateUserPassword.cpsp"
+#line 17 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\userUpdatePassword.cpsp"
const char* pageName = "Passwort bestimmen";
auto user = mSession->getNewUser();
auto sm = SessionManager::getInstance();
- auto uri_start = ServerConfig::g_serverPath;
+ auto uri_start = getBaseUrl();
PageState state = PAGE_STATE_ASK_PASSWORD;
// remove old cookies if exist
@@ -51,9 +51,12 @@ void UpdateUserPasswordPage::handleRequest(Poco::Net::HTTPServerRequest& request
if(!form.empty()) {
auto pwd = form.get("register-password", "");
if(pwd != "") {
+ if(!mSession->getLanguageCatalog()) {
+ mSession->setLanguage(LANG_EN);
+ }
if(pwd != form.get("register-password2", "")) {
mSession->addError(new Error("Passwort", "Passwörter sind nicht identisch."), false);
- } else if(SessionManager::getInstance()->checkPwdValidation(pwd, mSession)) {
+ } else if(SessionManager::getInstance()->checkPwdValidation(pwd, mSession, mSession->getLanguageCatalog())) {
auto sessionState = mSession->getSessionState();
if(user->setNewPassword(pwd) >= 0) {
@@ -94,7 +97,7 @@ void UpdateUserPasswordPage::handleRequest(Poco::Net::HTTPServerRequest& request
}
//getErrors(user);
//printf("session state end [UpdateUserPassword Page]: %s\n", mSession->getSessionStateString());
-#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 3 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
bool withMaterialIcons = false;
std::ostream& _responseStream = response.send();
@@ -109,20 +112,20 @@ void UpdateUserPasswordPage::handleRequest(Poco::Net::HTTPServerRequest& request
responseStream << " \n";
responseStream << " \n";
responseStream << "Gradido Login Server: ";
-#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 11 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
responseStream << ( pageName );
responseStream << " \n";
responseStream << " \n";
-#line 13 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 13 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
if(withMaterialIcons) { responseStream << "\n";
responseStream << " \n";
-#line 15 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
+#line 15 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\header.cpsp"
} responseStream << "\n";
responseStream << "\n";
responseStream << "\n";
@@ -130,20 +133,20 @@ void UpdateUserPasswordPage::handleRequest(Poco::Net::HTTPServerRequest& request
responseStream << " \n";
responseStream << " \n";
responseStream << " ";
-#line 6 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
+#line 6 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\footer.cpsp"
responseStream << ( mTimeProfiler.string() );
responseStream << "\n";
responseStream << "
\n";
responseStream << " \n";
responseStream << "
Login Server in Entwicklung
\n";
responseStream << "
Alpha ";
-#line 10 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
+#line 10 "F:\\Gradido\\gradido_local\\login_server\\src\\cpsp\\footer.cpsp"
responseStream << ( ServerConfig::g_versionString );
responseStream << "
\n";
responseStream << "
\n";
diff --git a/login_server/src/cpp/HTTPInterface/UserUpdatePasswordPage.h b/login_server/src/cpp/HTTPInterface/UserUpdatePasswordPage.h
new file mode 100644
index 000000000..b7373613c
--- /dev/null
+++ b/login_server/src/cpp/HTTPInterface/UserUpdatePasswordPage.h
@@ -0,0 +1,20 @@
+#ifndef UserUpdatePasswordPage_INCLUDED
+#define UserUpdatePasswordPage_INCLUDED
+
+
+#include "Poco/Net/HTTPRequestHandler.h"
+
+
+#include "SessionHTTPRequestHandler.h"
+
+
+class UserUpdatePasswordPage: public SessionHTTPRequestHandler
+{
+public:
+ UserUpdatePasswordPage(Session*);
+
+ void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response);
+};
+
+
+#endif // UserUpdatePasswordPage_INCLUDED
diff --git a/login_server/src/cpp/JSONInterface/JsonAdminEmailVerificationResend.cpp b/login_server/src/cpp/JSONInterface/JsonAdminEmailVerificationResend.cpp
index 8a11a0840..08be3cc26 100644
--- a/login_server/src/cpp/JSONInterface/JsonAdminEmailVerificationResend.cpp
+++ b/login_server/src/cpp/JSONInterface/JsonAdminEmailVerificationResend.cpp
@@ -100,7 +100,9 @@ Poco::JSON::Object* JsonAdminEmailVerificationResend::handle(Poco::Dynamic::Var
if (emailVerification.isNull()) {
return stateError("no email verification code found");
}
+
emailVerification->getModel()->insertIntoDB(false);
+ emailVerification->setBaseUrl(ServerConfig::g_serverPath + "/checkEmail");
em->addEmail(new model::Email(emailVerification, receiverUser, model::EMAIL_ADMIN_USER_VERIFICATION_CODE_RESEND));
return stateSuccess();
diff --git a/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp b/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp
index 381ded7e5..7fb40913e 100644
--- a/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp
+++ b/login_server/src/cpp/JSONInterface/JsonCreateTransaction.cpp
@@ -85,12 +85,13 @@ Poco::JSON::Object* JsonCreateTransaction::handle(Poco::Dynamic::Var params)
Poco::JSON::Object* JsonCreateTransaction::transfer(Poco::Dynamic::Var params)
{
+ static const char* function_name = "JsonCreateTransaction::transfer";
auto target_pubkey = getTargetPubkey(params);
if (!target_pubkey) {
return customStateError("not found", "receiver not found");
}
- auto user = mSession->getNewUser();
+ auto sender_user = mSession->getNewUser();
Poco::UInt32 amount = 0;
auto mm = MemoryManager::getInstance();
Poco::JSON::Object* result = nullptr;
@@ -107,6 +108,9 @@ Poco::JSON::Object* JsonCreateTransaction::transfer(Poco::Dynamic::Var params)
else {
result = stateError("parameter format unknown");
}
+ if (mMemo.size() < 5 || mMemo.size() > 150) {
+ result = stateError("memo is not set or not in expected range [5;150]");
+ }
if (result) {
mm->releaseMemory(target_pubkey);
return result;
@@ -121,25 +125,44 @@ Poco::JSON::Object* JsonCreateTransaction::transfer(Poco::Dynamic::Var params)
result = stateError("user not in group", "receiver user isn't in target group");
}
}
- auto sender_user = mSession->getNewUser();
- if (sender_user->getGradidoKeyPair()->isTheSame(*target_pubkey)) {
- result = stateError("sender and receiver are the same");
+
+ auto gradido_key_pair = sender_user->getGradidoKeyPair();
+ if (gradido_key_pair) {
+ if (gradido_key_pair->isTheSame(*target_pubkey)) {
+ result = stateError("sender and receiver are the same");
+ }
+ }
+ else {
+ printf("user hasn't valid key pair set\n");
}
if (!result) {
- auto transaction = model::gradido::Transaction::createTransfer(sender_user, target_pubkey, mTargetGroup, amount, mMemo, mBlockchainType);
+ try {
+ auto transaction = model::gradido::Transaction::createTransfer(sender_user, target_pubkey, mTargetGroup, amount, mMemo, mBlockchainType);
- if (mAutoSign) {
- Poco::JSON::Array errors;
- transaction->sign(user);
- if (transaction->errorCount() > 0) {
- errors.add(transaction->getErrorsArray());
- }
+ if (mAutoSign) {
+ Poco::JSON::Array errors;
+ transaction->sign(sender_user);
+ if (transaction->errorCount() > 0) {
+ errors.add(transaction->getErrorsArray());
+ }
- if (errors.size() > 0) {
- return stateError("error by signing transaction", errors);
+ if (errors.size() > 0) {
+ return stateError("error by signing transaction", errors);
+ }
}
}
-
+ catch (Poco::Exception& ex) {
+ NotificationList errors;
+ errors.addError(new ParamError(function_name, "poco exception: ", ex.displayText()));
+ errors.sendErrorsAsEmail();
+ return stateError("exception");
+ }
+ catch (std::exception& ex) {
+ NotificationList errors;
+ errors.addError(new ParamError(function_name, "std::exception: ", ex.what()));
+ errors.sendErrorsAsEmail();
+ return stateError("exception");
+ }
result = stateSuccess();
}
mm->releaseMemory(target_pubkey);
@@ -147,6 +170,7 @@ Poco::JSON::Object* JsonCreateTransaction::transfer(Poco::Dynamic::Var params)
}
Poco::JSON::Object* JsonCreateTransaction::creation(Poco::Dynamic::Var params)
{
+ static const char* function_name = "JsonCreateTransaction::creation";
auto target_pubkey = getTargetPubkey(params);
if (!target_pubkey) {
return customStateError("not found", "receiver not found");
@@ -205,11 +229,25 @@ Poco::JSON::Object* JsonCreateTransaction::creation(Poco::Dynamic::Var params)
}
if(!result) {
- auto transaction = model::gradido::Transaction::createCreation(mReceiverUser, amount, target_date, mMemo, mBlockchainType);
- if (mAutoSign) {
- if (!transaction->sign(mSession->getNewUser())) {
- return stateError("error by signing transaction", transaction);
+ try {
+ auto transaction = model::gradido::Transaction::createCreation(mReceiverUser, amount, target_date, mMemo, mBlockchainType);
+ if (mAutoSign) {
+ if (!transaction->sign(mSession->getNewUser())) {
+ return stateError("error by signing transaction", transaction);
+ }
}
+ }
+ catch (Poco::Exception& ex) {
+ NotificationList errors;
+ errors.addError(new ParamError(function_name, "poco exception: ", ex.displayText()));
+ errors.sendErrorsAsEmail();
+ return stateError("exception");
+ }
+ catch (std::exception& ex) {
+ NotificationList errors;
+ errors.addError(new ParamError(function_name, "std::exception: ", ex.what()));
+ errors.sendErrorsAsEmail();
+ return stateError("exception");
}
result = stateSuccess();
diff --git a/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp b/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp
index c66d10c8d..13ca5122f 100644
--- a/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp
+++ b/login_server/src/cpp/JSONInterface/JsonCreateUser.cpp
@@ -68,7 +68,7 @@ Poco::JSON::Object* JsonCreateUser::handle(Poco::Dynamic::Var params)
if (password.size()) {
NotificationList errors;
- if (!sm->checkPwdValidation(password, &errors)) {
+ if (!sm->checkPwdValidation(password, &errors, LanguageManager::getInstance()->getFreeCatalog(LANG_EN))) {
Poco::JSON::Object* result = new Poco::JSON::Object;
result->set("state", "error");
result->set("msg", errors.getLastError()->getString(false));
@@ -109,7 +109,7 @@ Poco::JSON::Object* JsonCreateUser::handle(Poco::Dynamic::Var params)
emailOptInModel->sendErrorsAsEmail();
return stateError("insert emailOptIn failed");
}
-
+ emailOptIn->setBaseUrl(user->getGroupBaseUrl() + 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/JSONInterface/JsonUnsecureLogin.cpp b/login_server/src/cpp/JSONInterface/JsonUnsecureLogin.cpp
index 077770927..0d151b1c3 100644
--- a/login_server/src/cpp/JSONInterface/JsonUnsecureLogin.cpp
+++ b/login_server/src/cpp/JSONInterface/JsonUnsecureLogin.cpp
@@ -55,7 +55,7 @@ Poco::JSON::Object* JsonUnsecureLogin::handle(Poco::Dynamic::Var params)
NotificationList pwd_errors;
Poco::JSON::Object* result = new Poco::JSON::Object;
- if (!password.size() || !sm->checkPwdValidation(password, &pwd_errors)) {
+ if (!password.size() || !sm->checkPwdValidation(password, &pwd_errors, LanguageManager::getInstance()->getFreeCatalog(LANG_EN))) {
result->set("state", "error");
result->set("msg", pwd_errors.getLastError()->getString(false));
diff --git a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp
index 4b55694af..40ec44b16 100644
--- a/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp
+++ b/login_server/src/cpp/JSONInterface/JsonUpdateUserInfos.cpp
@@ -124,7 +124,7 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params)
}
else {
NotificationList errors;
- if (!sm->checkPwdValidation(value.toString(), &errors)) {
+ if (!sm->checkPwdValidation(value.toString(), &errors, LanguageManager::getInstance()->getFreeCatalog(LANG_EN))) {
jsonErrorsArray.add("User.password isn't valid");
jsonErrorsArray.add(errors.getErrorsArray());
}
diff --git a/login_server/src/cpp/SingletonManager/SessionManager.cpp b/login_server/src/cpp/SingletonManager/SessionManager.cpp
index 6a08ebaab..30a6f6f61 100644
--- a/login_server/src/cpp/SingletonManager/SessionManager.cpp
+++ b/login_server/src/cpp/SingletonManager/SessionManager.cpp
@@ -596,30 +596,42 @@ void SessionManager::deleteLoginCookies(Poco::Net::HTTPServerRequest& request, P
//session_id = atoi(cookies.get("GRADIDO_LOGIN").data());
}
-bool SessionManager::checkPwdValidation(const std::string& pwd, NotificationList* errorReciver)
+bool SessionManager::checkPwdValidation(const std::string& pwd, NotificationList* errorReciver, Poco::AutoPtr lang)
{
if ((ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_ALLOW_ALL_PASSWORDS) == ServerConfig::UNSECURE_ALLOW_ALL_PASSWORDS) {
return true;
}
if (!isValid(pwd, VALIDATE_PASSWORD)) {
- errorReciver->addError(new Error("Passwort", "Bitte gebe ein gültiges Password ein mit mindestens 8 Zeichen, Groß- und Kleinbuchstaben, mindestens einer Zahl und einem Sonderzeichen (@$!%*?&+-_) ein!"));
+ errorReciver->addError(new Error(
+ lang->gettext("Password"),
+ lang->gettext("Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character (@$!%*?&+-_)!")));
// @$!%*?&+-
if (pwd.size() < 8) {
- errorReciver->addError(new Error("Passwort", "Dein Passwort ist zu kurz!"));
+ errorReciver->addError(new Error(
+ lang->gettext("Password"),
+ lang->gettext("Your password is to short!")));
}
else if (!isValid(pwd, VALIDATE_HAS_LOWERCASE_LETTER)) {
- errorReciver->addError(new Error("Passwort", "Dein Passwort enthält keine Kleinbuchstaben!"));
+ errorReciver->addError(new Error(
+ lang->gettext("Password"),
+ lang->gettext("Your password does not contain lowercase letters!")));
}
else if (!isValid(pwd, VALIDATE_HAS_UPPERCASE_LETTER)) {
- errorReciver->addError(new Error("Passwort", "Dein Passwort enthält keine Großbuchstaben!"));
+ errorReciver->addError(new Error(
+ lang->gettext("Password"),
+ lang->gettext("Your password does not contain any capital letters!")));
}
else if (!isValid(pwd, VALIDATE_HAS_NUMBER)) {
- errorReciver->addError(new Error("Passwort", "Dein Passwort enthält keine Zahlen!"));
+ errorReciver->addError(new Error(
+ lang->gettext("Password"),
+ lang->gettext("Your password does not contain any number!")));
}
else if (!isValid(pwd, VALIDATE_HAS_SPECIAL_CHARACTER)) {
- errorReciver->addError(new Error("Passwort", "Dein Passwort enthält keine Sonderzeichen (@$!%*?&+-)!"));
+ errorReciver->addError(new Error(
+ lang->gettext("Password"),
+ lang->gettext("Your password does not contain special characters (@$!%*?&+-)!")));
}
return false;
diff --git a/login_server/src/cpp/SingletonManager/SessionManager.h b/login_server/src/cpp/SingletonManager/SessionManager.h
index e20002856..2e05b907a 100644
--- a/login_server/src/cpp/SingletonManager/SessionManager.h
+++ b/login_server/src/cpp/SingletonManager/SessionManager.h
@@ -72,7 +72,7 @@ public:
bool isValid(const std::string& subject, SessionValidationTypes validationType);
//! \return true if password is valid
- bool checkPwdValidation(const std::string& pwd, NotificationList* errorReciver);
+ bool checkPwdValidation(const std::string& pwd, NotificationList* errorReciver, Poco::AutoPtr lang);
void checkTimeoutSession();
diff --git a/login_server/src/cpp/controller/EmailVerificationCode.cpp b/login_server/src/cpp/controller/EmailVerificationCode.cpp
index d685fd925..16fcefbb8 100644
--- a/login_server/src/cpp/controller/EmailVerificationCode.cpp
+++ b/login_server/src/cpp/controller/EmailVerificationCode.cpp
@@ -122,10 +122,7 @@ namespace controller {
std::string EmailVerificationCode::getLink()
{
std::string link = mBaseUrl;
- if (ServerConfig::g_frontend_checkEmailPath.size() > 1 && ServerConfig::g_frontend_checkEmailPath.data()[0] != '/') {
- link += '/';
- }
- link += ServerConfig::g_frontend_checkEmailPath;
+
if (link.data()[link.size() - 1] != '/') {
link += '/';
}
diff --git a/login_server/src/cpp/controller/HederaId.h b/login_server/src/cpp/controller/HederaId.h
index 5ec8dffdf..fb43cd82b 100644
--- a/login_server/src/cpp/controller/HederaId.h
+++ b/login_server/src/cpp/controller/HederaId.h
@@ -8,7 +8,7 @@
#include "TableControllerBase.h"
-#include "../proto/hedera/BasicTypes.pb.h"
+#include "proto/hedera/BasicTypes.pb.h"
namespace controller {
class HederaAccount;
@@ -43,4 +43,4 @@ namespace controller {
};
}
-#endif //GRADIDO_LOGIN_SERVER_CONTROLLER_HEDERA_ID_INCLUDE
\ No newline at end of file
+#endif //GRADIDO_LOGIN_SERVER_CONTROLLER_HEDERA_ID_INCLUDE
diff --git a/login_server/src/cpp/controller/User.cpp b/login_server/src/cpp/controller/User.cpp
index 5ea3594fc..7eeeef642 100644
--- a/login_server/src/cpp/controller/User.cpp
+++ b/login_server/src/cpp/controller/User.cpp
@@ -69,8 +69,8 @@ namespace controller {
using namespace Poco::Data::Keywords;
Poco::Data::Statement select(session);
- // typedef Poco::Tuple, int> UserTuple;
- select << "SELECT id, first_name, last_name, email, pubkey, created, email_checked, disabled FROM " << db->getTableName();
+ // typedef Poco::Tuple, Poco::DateTime, int, int, int> UserTuple;
+ select << "SELECT id, first_name, last_name, email, username, pubkey, created, email_checked, disabled, group_id FROM " << db->getTableName();
select << " where email_checked = 0 ";
select, into(resultFromDB);
if (searchString != "") {
diff --git a/login_server/src/cpp/lib/DRHashList.cpp b/login_server/src/cpp/lib/DRHashList.cpp
index b912f742c..62429b094 100644
--- a/login_server/src/cpp/lib/DRHashList.cpp
+++ b/login_server/src/cpp/lib/DRHashList.cpp
@@ -6,6 +6,7 @@
#include
#include
+#include
using namespace std;
diff --git a/login_server/src/cpp/lib/DataTypeConverter.h b/login_server/src/cpp/lib/DataTypeConverter.h
index b3fe436a5..d61944081 100644
--- a/login_server/src/cpp/lib/DataTypeConverter.h
+++ b/login_server/src/cpp/lib/DataTypeConverter.h
@@ -11,9 +11,9 @@
#include "Poco/JSON/Array.h"
#include "../SingletonManager/LanguageManager.h"
-#include "../proto/hedera/Timestamp.pb.h"
-#include "../proto/hedera/Duration.pb.h"
-#include "../proto/gradido/BasicTypes.pb.h"
+#include "proto/hedera/Timestamp.pb.h"
+#include "proto/hedera/Duration.pb.h"
+#include "proto/gradido/BasicTypes.pb.h"
#include "sodium.h"
@@ -37,13 +37,13 @@ namespace DataTypeConverter {
MemoryBin* hexToBin(const std::string& hexString);
MemoryBin* base64ToBin(const std::string& base64String, int variant = sodium_base64_VARIANT_ORIGINAL);
-
+
std::string binToBase64(const unsigned char* data, size_t size, int variant = sodium_base64_VARIANT_ORIGINAL);
inline std::string binToBase64(const MemoryBin* data, int variant = sodium_base64_VARIANT_ORIGINAL) { return binToBase64(data->data(), data->size(), variant); }
inline std::string binToBase64(const std::string& proto_bin, int variant = sodium_base64_VARIANT_ORIGINAL) {
return binToBase64((const unsigned char*)proto_bin.data(), proto_bin.size(), variant);
}
-
+
std::string binToHex(const unsigned char* data, size_t size);
std::string binToHex(const Poco::Nullable& nullableBin);
inline std::string binToHex(const MemoryBin* data) { return binToHex(data->data(), data->size());}
diff --git a/login_server/src/cpp/model/Session.cpp b/login_server/src/cpp/model/Session.cpp
index 3fbe05a98..c200cdc74 100644
--- a/login_server/src/cpp/model/Session.cpp
+++ b/login_server/src/cpp/model/Session.cpp
@@ -207,6 +207,10 @@ bool Session::createUserDirect(const std::string& first_name, const std::string&
auto em = ErrorManager::getInstance();
auto email_manager = EmailManager::getInstance();
+ if (mLanguageCatalog.isNull()) {
+ mLanguageCatalog = LanguageManager::getInstance()->getFreeCatalog(LANG_DE);
+ }
+
if (!sm->isValid(first_name, VALIDATE_NAME)) {
addError(new Error(gettext("Vorname"), gettext("Bitte gebe einen Namen an. Mindestens 3 Zeichen, keines folgender Zeichen <>&;")), false);
return false;
@@ -219,7 +223,8 @@ bool Session::createUserDirect(const std::string& first_name, const std::string&
addError(new Error(gettext("E-Mail"), gettext("Bitte gebe eine gültige E-Mail Adresse an.")), false);
return false;
}
- if (!sm->checkPwdValidation(password, this)) {
+
+ if (!sm->checkPwdValidation(password, this, mLanguageCatalog)) {
return false;
}
@@ -658,7 +663,13 @@ UserState Session::loadUser(const std::string& email, const std::string& passwor
if (mNewUser->getUserState() >= USER_LOADED_FROM_DB) {
NotificationList pwd_errors;
- if (!sm->checkPwdValidation(password, &pwd_errors))
+ auto lm = LanguageManager::getInstance();
+ auto lang_key = mNewUser->getModel()->getLanguageKey();
+ if (mLanguageCatalog.isNull()) {
+ mLanguageCatalog = lm->getFreeCatalog(lm->languageFromString(lang_key));
+ }
+
+ if (!sm->checkPwdValidation(password, &pwd_errors, mLanguageCatalog))
{
Poco::Thread::sleep(ServerConfig::g_FakeLoginSleepTime);
return USER_PASSWORD_INCORRECT;
diff --git a/login_server/src/cpp/model/email/Email.cpp b/login_server/src/cpp/model/email/Email.cpp
index 185f13f74..36c411413 100644
--- a/login_server/src/cpp/model/email/Email.cpp
+++ b/login_server/src/cpp/model/email/Email.cpp
@@ -5,7 +5,7 @@
#include "../gradido/TransactionBase.h"
-#include "../lib/DataTypeConverter.h"
+#include "../../lib/DataTypeConverter.h"
namespace model {
@@ -169,7 +169,7 @@ Gradido Login-Server\n\
std::string content_string;
switch (mType) {
- case EMAIL_DEFAULT:
+ case EMAIL_DEFAULT:
mailMessage->addRecipient(adminRecipient);
mailMessage->setSubject(langCatalog->gettext_str("Default Email Subject"));
mailMessage->addContent(new Poco::Net::StringPartSource(langCatalog->gettext_str("Empty Email Content"), mt.toString()));
@@ -180,7 +180,7 @@ Gradido Login-Server\n\
mailMessage->setSubject(langCatalog->gettext_str("Error from Gradido Login Server"));
mailMessage->addContent(new Poco::Net::StringPartSource(mErrorHtml, mt.toString()));
break;
-
+
case EMAIL_USER_VERIFICATION_CODE:
case EMAIL_USER_VERIFICATION_CODE_RESEND:
case EMAIL_USER_VERIFICATION_CODE_RESEND_AFTER_LONG_TIME:
@@ -284,7 +284,7 @@ Gradido Login-Server\n\
std::string Email::replaceUserNamesAndLink(
const char* src,
const std::string& first_name,
- const std::string& last_name,
+ const std::string& last_name,
const std::string& link,
Poco::UInt64 code
) {
@@ -300,7 +300,7 @@ Gradido Login-Server\n\
else {
addError(new Error(functionName, "no first_name placeholder found"));
}
-
+
findPos = result.find("[last_name]", findCursor);
if (findPos != result.npos) {
findCursor = findPos + last_name.size();
@@ -438,4 +438,4 @@ Gradido Login-Server\n\
return EMAIL_ERROR;
}
}
-}
\ No newline at end of file
+}
diff --git a/login_server/src/cpp/model/gradido/GroupMemberUpdate.cpp b/login_server/src/cpp/model/gradido/GroupMemberUpdate.cpp
index 145e1e97a..223baeb92 100644
--- a/login_server/src/cpp/model/gradido/GroupMemberUpdate.cpp
+++ b/login_server/src/cpp/model/gradido/GroupMemberUpdate.cpp
@@ -67,7 +67,7 @@ namespace model {
const static char functionName[] = { "GroupMemberUpdate::validate" };
if (mProtoMemberUpdate.user_pubkey().size() != KeyPairEd25519::getPublicKeySize()) {
addError(new Error(functionName, "pubkey not set or wrong size"));
- return TRANSCATION_VALID_INVALID_PUBKEY;
+ return TRANSACTION_VALID_INVALID_PUBKEY;
}
if (mProtoMemberUpdate.member_update_type() != proto::gradido::GroupMemberUpdate::ADD_USER) {
diff --git a/login_server/src/cpp/model/gradido/GroupMemberUpdate.h b/login_server/src/cpp/model/gradido/GroupMemberUpdate.h
index 7bd146cfd..6a58000b9 100644
--- a/login_server/src/cpp/model/gradido/GroupMemberUpdate.h
+++ b/login_server/src/cpp/model/gradido/GroupMemberUpdate.h
@@ -2,7 +2,7 @@
#define __GRADIDO_LOGIN_SERVER_MODEL_GRADIDO_GROUP_MEMBER_UPDATE_H
#include "TransactionBase.h"
-#include "../../proto/gradido/GroupMemberUpdate.pb.h"
+#include "proto/gradido/GroupMemberUpdate.pb.h"
namespace model {
@@ -26,4 +26,4 @@ namespace model {
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/login_server/src/cpp/model/gradido/Transaction.cpp b/login_server/src/cpp/model/gradido/Transaction.cpp
index c8708ce35..0301d4440 100644
--- a/login_server/src/cpp/model/gradido/Transaction.cpp
+++ b/login_server/src/cpp/model/gradido/Transaction.cpp
@@ -9,9 +9,9 @@
#include "../../controller/HederaAccount.h"
#include "../../controller/HederaRequest.h"
-#include "../lib/DataTypeConverter.h"
-#include "../lib/Profiler.h"
-#include "../lib/JsonRequest.h"
+#include "../../lib/DataTypeConverter.h"
+#include "../../lib/Profiler.h"
+#include "../../lib/JsonRequest.h"
#include "../hedera/Transaction.h"
#include "../hedera/TransactionId.h"
@@ -30,7 +30,7 @@ namespace model {
Transaction::Transaction(Poco::AutoPtr body)
: mTransactionBody(body), mBodyBytesHash(0)
{
-
+
auto body_bytes = mTransactionBody->getBodyBytes();
mBodyBytesHash = DRMakeStringHash(body_bytes.data(), body_bytes.size());
mProtoTransaction.set_body_bytes(body_bytes);
@@ -50,7 +50,7 @@ namespace model {
auto body_bytes = mTransactionBody->getBodyBytes();
mBodyBytesHash = DRMakeStringHash(body_bytes.data(), body_bytes.size());
}
-
+
Transaction::~Transaction()
{
Poco::ScopedLock _lock(mWorkMutex);
@@ -76,7 +76,7 @@ namespace model {
}
auto body = TransactionBody::create("", user, proto::gradido::GroupMemberUpdate_MemberUpdateType_ADD_USER, group_model->getAlias());
-
+
Poco::AutoPtr result = new Transaction(body);
auto model = result->getModel();
model->setHederaId(topic_id->getModel()->getID());
@@ -87,7 +87,7 @@ namespace model {
Poco::AutoPtr Transaction::createCreation(
Poco::AutoPtr receiver,
- Poco::UInt32 amount,
+ Poco::UInt32 amount,
Poco::DateTime targetDate,
const std::string& memo,
BlockchainType blockchainType
@@ -101,7 +101,7 @@ namespace model {
}
auto network_type = ServerConfig::g_HederaNetworkType;
auto receiver_model = receiver->getModel();
-
+
auto body = TransactionBody::create(memo, receiver, amount, targetDate, blockchainType);
Poco::AutoPtr result = new Transaction(body);
@@ -118,7 +118,7 @@ namespace model {
}
model->setHederaId(topic_id->getModel()->getID());
}
-
+
result->insertPendingTaskIntoDB(receiver, model::table::TASK_TYPE_CREATION);
PendingTasksManager::getInstance()->addTask(result);
return result;
@@ -129,7 +129,7 @@ namespace model {
const MemoryBin* receiverPubkey,
Poco::AutoPtr receiverGroup,
Poco::UInt32 amount,
- const std::string& memo,
+ const std::string& memo,
BlockchainType blockchainType,
bool inbound/* = true*/
)
@@ -143,25 +143,25 @@ namespace model {
if (sender.isNull() || !sender->getModel() || !receiverPubkey || !amount) {
return transaction;
}
-
+
auto sender_model = sender->getModel();
-
-
+
+
if (blockchainType == BLOCKCHAIN_MYSQL) {
transaction_body = TransactionBody::create(memo, sender, receiverPubkey, amount, blockchainType);
transaction = new Transaction(transaction_body);
}
- else if (blockchainType == BLOCKCHAIN_HEDERA)
+ else if (blockchainType == BLOCKCHAIN_HEDERA)
{
auto network_type = ServerConfig::g_HederaNetworkType;
-
-
+
+
// LOCAL Transfer
if (receiverGroup.isNull() || sender_model->getGroupId() == receiverGroup->getModel()->getID())
{
topic_id = controller::HederaId::find(sender_model->getGroupId(), network_type);
- if (topic_id.isNull())
+ if (topic_id.isNull())
{
em->addError(new ParamError(function_name, "could'n find topic for group: ", sender_model->getGroupId()));
em->addError(new ParamError(function_name, "network type: ", network_type));
@@ -220,7 +220,7 @@ namespace model {
transaction_model->setHederaId(topic_id->getModel()->getID());
}
-
+
transaction->setParam("blockchain_type", (int)blockchainType);
transaction->insertPendingTaskIntoDB(sender, model::table::TASK_TYPE_TRANSFER);
PendingTasksManager::getInstance()->addTask(transaction);
@@ -249,10 +249,10 @@ namespace model {
}
Poco::AutoPtr Transaction::createTransfer(
- const MemoryBin* senderPubkey,
- Poco::AutoPtr receiver,
- std::string senderGroupAlias,
- Poco::UInt32 amount,
+ const MemoryBin* senderPubkey,
+ Poco::AutoPtr receiver,
+ std::string senderGroupAlias,
+ Poco::UInt32 amount,
const std::string& memo,
BlockchainType blockchainType
)
@@ -268,7 +268,7 @@ namespace model {
//std::vector> bodys;
auto receiver_model = receiver->getModel();
auto network_type = ServerConfig::g_HederaNetworkType;
-
+
auto sender_groups = controller::Group::load(senderGroupAlias);
if (!sender_groups.size()) {
em->addError(new ParamError(function_name, "couldn't find group", senderGroupAlias));
@@ -286,10 +286,10 @@ namespace model {
Poco::Timestamp pairedTransactionId;
// create only inbound transaction, and outbound before sending to hedera
//for (int i = 0; i < 1; i++) {
-
+
//transaction_group = receiverGroup;
//topic_group = sender_group;
-
+
if (transaction_group.isNull()) {
em->addError(new Error(function_name, "transaction group is zero, inbound"));
em->sendErrorsAsEmail();
@@ -314,7 +314,7 @@ namespace model {
return result;
}
-
+
Poco::AutoPtr Transaction::load(model::table::PendingTask* dbModel)
{
@@ -335,10 +335,10 @@ namespace model {
if (!finished) {
transaction->ifEnoughSignsProceed(nullptr);
}
-
+
return transaction;
}
-
+
bool Transaction::insertPendingTaskIntoDB(Poco::AutoPtr user, model::table::TaskType type)
{
static const char* function_name = "Transaction::insertPendingTaskIntoDB";
@@ -355,7 +355,7 @@ namespace model {
model->setTaskType(type);
model->setRequest(mProtoTransaction.SerializeAsString());
if (!model->insertIntoDB(true)) {
-
+
return false;
}
return true;
@@ -365,8 +365,8 @@ namespace model {
{
static const char function_name[] = "Transaction::addSign";
Poco::ScopedLock _lock(mWorkMutex);
-
- if (user.isNull() || !user->getModel())
+
+ if (user.isNull() || !user->getModel())
{
addError(new Error(function_name, "error user is invalid"));
return false;
@@ -381,9 +381,9 @@ namespace model {
}
auto hash = DRMakeStringHash(bodyBytes.data(), bodyBytes.size());
-
+
auto sigMap = mProtoTransaction.mutable_sig_map();
- if (sigMap->sigpair_size() > 0 && mBodyBytesHash && mBodyBytesHash != hash)
+ if (sigMap->sigpair_size() > 0 && mBodyBytesHash && mBodyBytesHash != hash)
{
addError(new Error(function_name, "body bytes hash has changed and signature(s) exist already!"));
return false;
@@ -413,33 +413,33 @@ namespace model {
auto gradido_key_pair = user->getGradidoKeyPair();
KeyPairEd25519* recovered_gradido_key_pair = nullptr;
- if (!gradido_key_pair || !gradido_key_pair->hasPrivateKey())
+ if (!gradido_key_pair || !gradido_key_pair->hasPrivateKey())
{
- if (!user->tryLoadPassphraseUserBackup(&recovered_gradido_key_pair))
+ if (!user->tryLoadPassphraseUserBackup(&recovered_gradido_key_pair))
{
- if (user->setGradidoKeyPair(recovered_gradido_key_pair))
+ if (user->setGradidoKeyPair(recovered_gradido_key_pair))
{
user->getModel()->updatePrivkey();
}
- }
- else
+ }
+ else
{
addError(new Error(function_name, "user cannot decrypt private key"));
return false;
}
}
-
+
MemoryBin* sign = nullptr;
- if (gradido_key_pair)
+ if (gradido_key_pair)
{
sign = gradido_key_pair->sign(bodyBytes);
}
- else if (recovered_gradido_key_pair)
+ else if (recovered_gradido_key_pair)
{
sign = recovered_gradido_key_pair->sign(bodyBytes);
}
- if (!sign)
+ if (!sign)
{
ErrorManager::getInstance()->sendErrorsAsEmail();
addError(new Error(function_name, "error by calculate signature"));
@@ -457,7 +457,7 @@ namespace model {
mm->releaseMemory(sign);
updateRequestInDB();
-
+
return ifEnoughSignsProceed(user);
}
@@ -509,7 +509,7 @@ namespace model {
// check if all signatures belong to current body bytes
auto body_bytes = mProtoTransaction.body_bytes();
- for (auto it = sig_map.sigpair().begin(); it != sig_map.sigpair().end(); it++)
+ for (auto it = sig_map.sigpair().begin(); it != sig_map.sigpair().end(); it++)
{
KeyPairEd25519 key_pair((const unsigned char*)it->pubkey().data());
if (!key_pair.verify(body_bytes, it->ed25519())) {
@@ -537,7 +537,7 @@ namespace model {
addError(new ParamError(function_name, "user public key has invalid size: ", pubkey_size));
return false;
}
- for (auto it = sig_pairs.begin(); it != sig_pairs.end(); it++)
+ for (auto it = sig_pairs.begin(); it != sig_pairs.end(); it++)
{
if (it->pubkey().size() != KeyPairEd25519::getPublicKeySize()) {
addError(new ParamError(function_name, "signed public key has invalid length: ", it->pubkey().size()));
@@ -589,8 +589,8 @@ namespace model {
static const char* function_name = "Transaction::runSendTransaction";
auto result = validate();
if (TRANSACTION_VALID_OK != result) {
- if ( TRANSACTION_VALID_MISSING_SIGN == result || TRANSACTION_VALID_CODE_ERROR == result
- || TRANSACTION_VALID_MISSING_PARAM == result || TRANSCATION_VALID_INVALID_PUBKEY == result
+ if ( TRANSACTION_VALID_MISSING_SIGN == result || TRANSACTION_VALID_CODE_ERROR == result
+ || TRANSACTION_VALID_MISSING_PARAM == result || TRANSACTION_VALID_INVALID_PUBKEY == result
|| TRANSACTION_VALID_INVALID_SIGN == result) {
addError(new ParamError(function_name, "code error", TransactionValidationToString(result)));
//sendErrorsAsEmail();
@@ -599,20 +599,20 @@ namespace model {
addError(new ParamError(function_name, "validation return: ", TransactionValidationToString(result)));
//sendErrorsAsEmail();
}
- else
+ else
{
-
+
std::string error_name;
std::string error_description;
auto lm = LanguageManager::getInstance();
auto user_model = getUser()->getModel();
auto t = lm->getFreeCatalog(lm->languageFromString(user_model->getLanguageKey()));
switch (result) {
- case TRANSACTION_VALID_FORBIDDEN_SIGN:
+ case TRANSACTION_VALID_FORBIDDEN_SIGN:
error_name = t->gettext_str("Signature Error");
error_description = t->gettext_str("Invalid signature!");
break;
- case TRANSACTION_VALID_INVALID_TARGET_DATE:
+ case TRANSACTION_VALID_INVALID_TARGET_DATE:
error_name = t->gettext_str("Creation Error");
error_description = t->gettext_str("Invalid target date! No future and only 3 month in the past.");
break;
@@ -628,7 +628,7 @@ namespace model {
error_name = t->gettext_str("Group Error");
error_description = t->gettext_str("Invalid Group Alias! I didn't know group, please check alias and try again.");
break;
- default:
+ default:
error_name = t->gettext_str("Unknown Error");
error_description = t->gettext_str("Admin gets an E-Mail");
addError(new ParamError(function_name, "unknown error", TransactionValidationToString(result)));
@@ -738,7 +738,7 @@ namespace model {
auto hedera_precheck_code_string = hedera_transaction_response->getPrecheckCodeString();
auto precheck_code = hedera_transaction_response->getPrecheckCode();
auto cost = hedera_transaction_response->getCost();
-
+
// for showing in docker
std::clog << "hedera response: " << hedera_precheck_code_string
<< ", cost: " << cost
@@ -791,7 +791,7 @@ namespace model {
return -4;
}
return 0;
-
+
}
int Transaction::runSendTransactionMysql()
{
@@ -807,10 +807,10 @@ namespace model {
auto base_64_message = DataTypeConverter::binToBase64(raw_message, sodium_base64_VARIANT_URLSAFE_NO_PADDING);
if (base_64_message == "") {
- addError(new Error(function_name, "error convert final transaction to base64"));
+ addError(new Error(function_name, "error convert final transaction to base64"));
return -7;
}
-
+
// create json request
auto user = getUser();
@@ -834,7 +834,7 @@ namespace model {
}
return 1;
}
-
+
getErrors(&json_request);
return -1;
@@ -888,8 +888,8 @@ namespace model {
return json_message;
}
-
-
+
+
/// TASK ////////////////////////
SendTransactionTask::SendTransactionTask(Poco::AutoPtr transaction)
: UniLib::controller::CPUTask(ServerConfig::g_CPUScheduler), mTransaction(transaction)
@@ -938,4 +938,4 @@ namespace model {
}
}
-}
\ No newline at end of file
+}
diff --git a/login_server/src/cpp/model/gradido/Transaction.h b/login_server/src/cpp/model/gradido/Transaction.h
index 9ff59100e..87dd487a2 100644
--- a/login_server/src/cpp/model/gradido/Transaction.h
+++ b/login_server/src/cpp/model/gradido/Transaction.h
@@ -3,23 +3,23 @@
/*
* @author: Dario Rekowski
- *
+ *
* @date: 12.10.2020
- *
- * @brief: mainly for signing gradido transaction
+ *
+ * @brief: mainly for signing gradido transaction
*/
-#include "../../proto/gradido/GradidoTransaction.pb.h"
+#include "proto/gradido/GradidoTransaction.pb.h"
#include "TransactionBody.h"
#include "../../tasks/GradidoTask.h"
#include "../../controller/User.h"
-#include "../tasks/CPUTask.h"
+#include "../../tasks/CPUTask.h"
namespace model {
namespace gradido {
-
+
class Transaction : public GradidoTask
{
@@ -32,21 +32,21 @@ namespace model {
// groupMemberUpdate
static Poco::AutoPtr createGroupMemberUpdate(Poco::AutoPtr user, Poco::AutoPtr group);
//! \brief transfer
- //! \return
+ //! \return
static Poco::AutoPtr createTransfer(
- Poco::AutoPtr sender,
- const MemoryBin* receiverPubkey,
- Poco::AutoPtr receiverGroup,
- Poco::UInt32 amount,
- const std::string& memo,
+ Poco::AutoPtr sender,
+ const MemoryBin* receiverPubkey,
+ Poco::AutoPtr receiverGroup,
+ Poco::UInt32 amount,
+ const std::string& memo,
BlockchainType blockchainType,
bool inbound = true);
Poco::AutoPtr createTransfer(
- const MemoryBin* senderPubkey,
+ const MemoryBin* senderPubkey,
Poco::AutoPtr receiver,
- std::string senderGroupAlias,
- Poco::UInt32 amount,
+ std::string senderGroupAlias,
+ Poco::UInt32 amount,
const std::string& memo,
BlockchainType blockchainType);
@@ -66,7 +66,7 @@ namespace model {
//! \brief validate and if valid send transaction via Hedera Consensus Service to node server
int runSendTransaction();
-
+
inline Poco::AutoPtr getTransactionBody() { Poco::ScopedLock _lock(mWorkMutex); return mTransactionBody; }
//! \brief get current body bytes from proto transaction and save it into db
diff --git a/login_server/src/cpp/model/gradido/TransactionBase.cpp b/login_server/src/cpp/model/gradido/TransactionBase.cpp
index 823a4c5ea..a8c983532 100644
--- a/login_server/src/cpp/model/gradido/TransactionBase.cpp
+++ b/login_server/src/cpp/model/gradido/TransactionBase.cpp
@@ -17,7 +17,7 @@ namespace model {
case TRANSACTION_VALID_INVALID_TARGET_DATE: return "invalid target date";
case TRANSACTION_VALID_CREATION_OUT_OF_BORDER: return "creation out of border";
case TRANSACTION_VALID_INVALID_AMOUNT: return "invalid amount";
- case TRANSCATION_VALID_INVALID_PUBKEY: return "invalid pubkey";
+ case TRANSACTION_VALID_INVALID_PUBKEY: return "invalid pubkey";
case TRANSACTION_VALID_INVALID_GROUP_ALIAS: return "invalid group alias";
case TRANSACTION_VALID_INVALID_SIGN: return "invalid sign";
}
diff --git a/login_server/src/cpp/model/gradido/TransactionBase.h b/login_server/src/cpp/model/gradido/TransactionBase.h
index bea79c971..9f5a87d85 100644
--- a/login_server/src/cpp/model/gradido/TransactionBase.h
+++ b/login_server/src/cpp/model/gradido/TransactionBase.h
@@ -11,11 +11,11 @@
#pragma warning(disable:4800)
-#include "../lib/NotificationList.h"
-#include "../proto/gradido/BasicTypes.pb.h"
-#include "../SingletonManager/MemoryManager.h"
+#include "../../lib/NotificationList.h"
+#include "proto/gradido/BasicTypes.pb.h"
+#include "../../SingletonManager/MemoryManager.h"
-#include "../controller/User.h"
+#include "../../controller/User.h"
namespace model {
namespace gradido {
@@ -29,9 +29,10 @@ namespace model {
TRANSACTION_VALID_INVALID_TARGET_DATE,
TRANSACTION_VALID_CREATION_OUT_OF_BORDER,
TRANSACTION_VALID_INVALID_AMOUNT,
- TRANSCATION_VALID_INVALID_PUBKEY,
+ TRANSACTION_VALID_INVALID_PUBKEY,
TRANSACTION_VALID_INVALID_GROUP_ALIAS,
- TRANSACTION_VALID_INVALID_SIGN
+ TRANSACTION_VALID_INVALID_SIGN,
+ TRANSACTION_VALID_INVALID_MEMO
};
const char* TransactionValidationToString(TransactionValidation result);
@@ -40,7 +41,7 @@ namespace model {
public:
TransactionBase(const std::string& memo);
virtual ~TransactionBase();
- //! \return 0 if ok, < 0 if error, > 0 if not implemented
+ //! \return 0 if ok, < 0 if error, > 0 if not implemented
virtual int prepare() = 0;
virtual TransactionValidation validate() = 0;
@@ -72,4 +73,4 @@ namespace model {
-#endif //GRADIDO_LOGIN_SERVER_MODEL_TRANSACTION_BASE_INCLUDE
\ No newline at end of file
+#endif //GRADIDO_LOGIN_SERVER_MODEL_TRANSACTION_BASE_INCLUDE
diff --git a/login_server/src/cpp/model/gradido/TransactionBody.h b/login_server/src/cpp/model/gradido/TransactionBody.h
index 92ad2f2b5..af7d97b27 100644
--- a/login_server/src/cpp/model/gradido/TransactionBody.h
+++ b/login_server/src/cpp/model/gradido/TransactionBody.h
@@ -7,7 +7,7 @@
#include "TransactionCreation.h"
#include "TransactionTransfer.h"
-#include "../../proto/gradido/TransactionBody.pb.h"
+#include "proto/gradido/TransactionBody.pb.h"
#include "../../lib/MultithreadContainer.h"
@@ -39,24 +39,24 @@ namespace model {
//! \brief GroupMemberUpdate Transaction
static Poco::AutoPtr create(const std::string& memo, Poco::AutoPtr user, proto::gradido::GroupMemberUpdate_MemberUpdateType type, const std::string& targetGroupAlias);
//! \brief GradidoTransfer Transaction
- //! \param group if group.isNull() it is a local transfer, else cross group transfer,
+ //! \param group if group.isNull() it is a local transfer, else cross group transfer,
//! \param group if group is same as sender group outbound, else inbound
static Poco::AutoPtr create(
const std::string& memo,
- Poco::AutoPtr sender,
- const MemoryBin* receiverPublicKey,
- Poco::UInt32 amount,
+ Poco::AutoPtr sender,
+ const MemoryBin* receiverPublicKey,
+ Poco::UInt32 amount,
BlockchainType blockchainType,
- Poco::Timestamp pairedTransactionId = Poco::Timestamp(),
+ Poco::Timestamp pairedTransactionId = Poco::Timestamp(),
Poco::AutoPtr group = nullptr
);
static Poco::AutoPtr create(const std::string& memo, const MemoryBin* senderPublicKey, Poco::AutoPtr receiver, Poco::UInt32 amount, Poco::Timestamp pairedTransactionId = Poco::Timestamp(), Poco::AutoPtr group = nullptr);
static Poco::AutoPtr create(const std::string& memo, const MemoryBin* senderPublicKey, const MemoryBin* receiverPublicKey, Poco::UInt32 amount, const std::string groupAlias, TransactionTransferType transferType, Poco::Timestamp pairedTransactionId = Poco::Timestamp());
//! \brief GradidoCreation Transaction
static Poco::AutoPtr create(
- const std::string& memo,
- Poco::AutoPtr receiver,
- Poco::UInt32 amount,
+ const std::string& memo,
+ Poco::AutoPtr receiver,
+ Poco::UInt32 amount,
Poco::DateTime targetDate,
BlockchainType blockchainType
);
@@ -68,7 +68,7 @@ namespace model {
static const char* transactionTypeToString(TransactionType type);
std::string getMemo();
void setMemo(const std::string& memo);
-
+
bool isCreation() { Poco::ScopedLock _lock(mWorkMutex); return mType == TRANSACTION_CREATION; }
bool isTransfer() { Poco::ScopedLock _lock(mWorkMutex); return mType == TRANSACTION_TRANSFER; }
bool isGroupMemberUpdate() { Poco::ScopedLock _lock(mWorkMutex); return mType == TRANSACTION_GROUP_MEMBER_UPDATE; }
@@ -97,4 +97,4 @@ namespace model {
}
}
-#endif //GRADIDO_LOGIN_SERVER_MODEL_GRADIDO_TRANSACTION_BASE_H
\ No newline at end of file
+#endif //GRADIDO_LOGIN_SERVER_MODEL_GRADIDO_TRANSACTION_BASE_H
diff --git a/login_server/src/cpp/model/gradido/TransactionCreation.cpp b/login_server/src/cpp/model/gradido/TransactionCreation.cpp
index e53a5544b..7461b9bce 100644
--- a/login_server/src/cpp/model/gradido/TransactionCreation.cpp
+++ b/login_server/src/cpp/model/gradido/TransactionCreation.cpp
@@ -108,7 +108,7 @@ namespace model {
if (mProtoCreation.receiver().pubkey().size() != KeyPairEd25519::getPublicKeySize()) {
addError(new Error(function_name, "receiver pubkey has invalid size"));
- return TRANSCATION_VALID_INVALID_PUBKEY;
+ return TRANSACTION_VALID_INVALID_PUBKEY;
}
// TODO: check creation amount from last 3 month from node server
diff --git a/login_server/src/cpp/model/gradido/TransactionCreation.h b/login_server/src/cpp/model/gradido/TransactionCreation.h
index 7304f49cd..5b7e592d8 100644
--- a/login_server/src/cpp/model/gradido/TransactionCreation.h
+++ b/login_server/src/cpp/model/gradido/TransactionCreation.h
@@ -12,8 +12,8 @@
#pragma warning(disable:4800)
#include "TransactionBase.h"
-#include "../proto/gradido/GradidoCreation.pb.h"
-#include "../controller/User.h"
+#include "proto/gradido/GradidoCreation.pb.h"
+#include "../../controller/User.h"
namespace model {
namespace gradido {
@@ -47,4 +47,4 @@ namespace model {
}
-#endif //GRADIDO_LOGIN_SERVER_MODEL_TRANSACTION_CREATION_INCLUDE
\ No newline at end of file
+#endif //GRADIDO_LOGIN_SERVER_MODEL_TRANSACTION_CREATION_INCLUDE
diff --git a/login_server/src/cpp/model/gradido/TransactionTransfer.cpp b/login_server/src/cpp/model/gradido/TransactionTransfer.cpp
index 6e458a87a..ef0d3a3f6 100644
--- a/login_server/src/cpp/model/gradido/TransactionTransfer.cpp
+++ b/login_server/src/cpp/model/gradido/TransactionTransfer.cpp
@@ -176,11 +176,19 @@ namespace model {
}
if (receiver_pubkey->size() != KeyPairEd25519::getPublicKeySize()) {
addError(new Error(function_name, "invalid size of receiver pubkey"));
- return TRANSCATION_VALID_INVALID_PUBKEY;
+ return TRANSACTION_VALID_INVALID_PUBKEY;
}
if (sender->pubkey().size() != KeyPairEd25519::getPublicKeySize()) {
addError(new Error(function_name, "invalid size of sender pubkey"));
- return TRANSCATION_VALID_INVALID_PUBKEY;
+ return TRANSACTION_VALID_INVALID_PUBKEY;
+ }
+ if(0 == memcmp(sender->pubkey().data(), receiver_pubkey->data(), KeyPairEd25519::getPublicKeySize())) {
+ addError(new Error(function_name, "sender and receiver are the same"));
+ return TRANSACTION_VALID_INVALID_PUBKEY;
+ }
+ if (mMemo.size() < 5 || mMemo.size() > 150) {
+ addError(new Error(function_name, "memo is not set or not in expected range [5;150]"));
+ return TRANSACTION_VALID_INVALID_MEMO;
}
return TRANSACTION_VALID_OK;
}
diff --git a/login_server/src/cpp/model/gradido/TransactionTransfer.h b/login_server/src/cpp/model/gradido/TransactionTransfer.h
index 57259059f..86da71207 100644
--- a/login_server/src/cpp/model/gradido/TransactionTransfer.h
+++ b/login_server/src/cpp/model/gradido/TransactionTransfer.h
@@ -15,7 +15,7 @@
//#include "Transaction.h"
#include "../proto/gradido/GradidoTransfer.pb.h"
-#include "../controller/User.h"
+#include "../../controller/User.h"
namespace model {
namespace gradido {
@@ -81,4 +81,4 @@ namespace model {
}
-#endif //GRADIDO_LOGIN_SERVER_MODEL_TRANSACTION_TRANSFER_INCLUDE
\ No newline at end of file
+#endif //GRADIDO_LOGIN_SERVER_MODEL_TRANSACTION_TRANSFER_INCLUDE
diff --git a/login_server/src/cpp/model/hedera/ConsensusCreateTopic.h b/login_server/src/cpp/model/hedera/ConsensusCreateTopic.h
index b639ee305..6dbd64257 100644
--- a/login_server/src/cpp/model/hedera/ConsensusCreateTopic.h
+++ b/login_server/src/cpp/model/hedera/ConsensusCreateTopic.h
@@ -4,11 +4,11 @@
#include "../../SingletonManager/MemoryManager.h"
#include "../../controller/HederaId.h"
-#include "../../proto/hedera/ConsensusCreateTopic.pb.h"
+#include "proto/hedera/ConsensusCreateTopic.pb.h"
namespace model {
namespace hedera {
- class ConsensusCreateTopic
+ class ConsensusCreateTopic
{
public:
ConsensusCreateTopic(Poco::AutoPtr autoRenewHederaAccountId, Poco::UInt32 autoRenewPeriod);
@@ -29,4 +29,4 @@ namespace model {
}
-#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_CREATE_TOPIC_H
\ No newline at end of file
+#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_CREATE_TOPIC_H
diff --git a/login_server/src/cpp/model/hedera/ConsensusSubmitMessage.h b/login_server/src/cpp/model/hedera/ConsensusSubmitMessage.h
index d08b72279..30b18664f 100644
--- a/login_server/src/cpp/model/hedera/ConsensusSubmitMessage.h
+++ b/login_server/src/cpp/model/hedera/ConsensusSubmitMessage.h
@@ -1,7 +1,7 @@
#ifndef __GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_SUBMIT_MESSAGE_H
#define __GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_SUBMIT_MESSAGE_H
-#include "../../proto/hedera/ConsensusSubmitMessage.pb.h"
+#include "proto/hedera/ConsensusSubmitMessage.pb.h"
#include "../../controller/HederaId.h"
namespace model {
@@ -20,7 +20,7 @@ namespace model {
bool validate();
-
+
protected:
proto::ConsensusSubmitMessageTransactionBody* mConsensusMessageBody;
@@ -29,4 +29,4 @@ namespace model {
}
}
-#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_SUBMIT_MESSAGE_H
\ No newline at end of file
+#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_SUBMIT_MESSAGE_H
diff --git a/login_server/src/cpp/model/hedera/ConsensusTopicInfo.h b/login_server/src/cpp/model/hedera/ConsensusTopicInfo.h
index 123b9496b..c25819498 100644
--- a/login_server/src/cpp/model/hedera/ConsensusTopicInfo.h
+++ b/login_server/src/cpp/model/hedera/ConsensusTopicInfo.h
@@ -2,7 +2,7 @@
#define __GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_GET_TOPIC_INFO_RESPONSE_H
#include "../proto/hedera/ConsensusTopicInfo.pb.h"
-#include "../SingletonManager/MemoryManager.h"
+#include "../../SingletonManager/MemoryManager.h"
#include "../../lib/DataTypeConverter.h"
#include "Poco/DateTime.h"
@@ -31,4 +31,4 @@ namespace model
}
}
-#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_GET_TOPIC_INFO_RESPONSE_H
\ No newline at end of file
+#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CONSENSUS_GET_TOPIC_INFO_RESPONSE_H
diff --git a/login_server/src/cpp/model/hedera/CryptoCreateTransaction.h b/login_server/src/cpp/model/hedera/CryptoCreateTransaction.h
index 7182f3506..8cb4f9039 100644
--- a/login_server/src/cpp/model/hedera/CryptoCreateTransaction.h
+++ b/login_server/src/cpp/model/hedera/CryptoCreateTransaction.h
@@ -1,9 +1,9 @@
#ifndef __GRADIDO_LOGIN_MODEL_HEDERA_CRYPTO_CREATE_TRANSACTION_H
#define __GRADIDO_LOGIN_MODEL_HEDERA_CRYPTO_CREATE_TRANSACTION_H
-#include "../../proto/hedera/CryptoCreate.pb.h"
+#include "proto/hedera/CryptoCreate.pb.h"
-#include "../Crypto/KeyPairHedera.h"
+#include "../../Crypto/KeyPairHedera.h"
namespace model {
namespace hedera {
@@ -28,4 +28,4 @@ namespace model {
-#endif //__GRADIDO_LOGIN_MODEL_HEDERA_CRYPTO_CREATE_TRANSACTION_H
\ No newline at end of file
+#endif //__GRADIDO_LOGIN_MODEL_HEDERA_CRYPTO_CREATE_TRANSACTION_H
diff --git a/login_server/src/cpp/model/hedera/CryptoTransferTransaction.h b/login_server/src/cpp/model/hedera/CryptoTransferTransaction.h
index 21d9bd3c3..6b1db2405 100644
--- a/login_server/src/cpp/model/hedera/CryptoTransferTransaction.h
+++ b/login_server/src/cpp/model/hedera/CryptoTransferTransaction.h
@@ -10,7 +10,7 @@
*
*/
-#include "../../proto/hedera/CryptoTransfer.pb.h"
+#include "proto/hedera/CryptoTransfer.pb.h"
#include "../../controller/HederaId.h"
namespace model {
@@ -37,4 +37,4 @@ namespace model {
}
-#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CRYPTO_TRANSFER_TRANSACTION_H
\ No newline at end of file
+#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_CRYPTO_TRANSFER_TRANSACTION_H
diff --git a/login_server/src/cpp/model/hedera/Query.h b/login_server/src/cpp/model/hedera/Query.h
index 0f149684c..4ed22d5b4 100644
--- a/login_server/src/cpp/model/hedera/Query.h
+++ b/login_server/src/cpp/model/hedera/Query.h
@@ -3,14 +3,14 @@
/*!
* @author: Dario Rekowski
- *
+ *
* @date: 31.08.20
- *
+ *
* @brief: class for put together hedera querys (ask for state data, not a transaction, but needs a payment transaction)
*
*/
-#include "../../proto/hedera/Query.pb.h"
+#include "proto/hedera/Query.pb.h"
#include "../../controller/NodeServer.h"
#include "../../Crypto/KeyPairHedera.h"
#include "TransactionBody.h"
@@ -39,7 +39,7 @@ namespace model {
void setResponseType(proto::ResponseType type);
proto::ResponseType getResponseType();
inline bool setTransactionFee(Poco::UInt64 fee) { return mTransactionBody->updateCryptoTransferAmount(fee);}
-
+
inline const proto::Query* getProtoQuery() const { return &mQueryProto; }
std::string getConnectionString() const;
@@ -57,4 +57,4 @@ namespace model {
}
-#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_QUERY_H
\ No newline at end of file
+#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_QUERY_H
diff --git a/login_server/src/cpp/model/hedera/Response.h b/login_server/src/cpp/model/hedera/Response.h
index ea2445774..af5a36d80 100644
--- a/login_server/src/cpp/model/hedera/Response.h
+++ b/login_server/src/cpp/model/hedera/Response.h
@@ -10,7 +10,7 @@
*
*/
-#include "../../proto/hedera/Response.pb.h"
+#include "proto/hedera/Response.pb.h"
#include "ConsensusTopicInfo.h"
#include "TransactionReceipt.h"
#include "TransactionRecord.h"
@@ -23,7 +23,7 @@ namespace model {
public:
Response();
~Response();
-
+
inline proto::Response* getResponsePtr() { return &mResponseProto; }
Poco::UInt64 getAccountBalance();
std::unique_ptr getConsensusTopicInfo();
@@ -31,17 +31,17 @@ namespace model {
TransactionRecord* getTransactionRecord();
Poco::UInt64 getQueryCost();
proto::ResponseCodeEnum getResponseCode();
-
+
inline bool isCryptoGetAccountBalanceResponse() { return mResponseProto.has_cryptogetaccountbalance(); }
inline bool isConsensusGetTopicInfoResponse() { return mResponseProto.has_consensusgettopicinfo(); }
protected:
proto::Response mResponseProto;
-
+
};
}
}
-#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_RESPONSE_H
\ No newline at end of file
+#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_RESPONSE_H
diff --git a/login_server/src/cpp/model/hedera/Transaction.h b/login_server/src/cpp/model/hedera/Transaction.h
index 63d273eb0..6ba7e9511 100644
--- a/login_server/src/cpp/model/hedera/Transaction.h
+++ b/login_server/src/cpp/model/hedera/Transaction.h
@@ -10,7 +10,7 @@
*
*/
-#include "../../proto/hedera/Transaction.pb.h"
+#include "proto/hedera/Transaction.pb.h"
#include "../../Crypto/KeyPairHedera.h"
#include "TransactionBody.h"
@@ -25,7 +25,7 @@ namespace model {
bool sign(std::unique_ptr keyPairHedera, const TransactionBody* transactionBody);
bool sign(std::unique_ptr keyPairHedera, std::unique_ptr transactionBody);
-
+
inline proto::Transaction* getTransaction() { return mTransaction; }
inline std::string getConnectionString() const { return mConnection.getUriWithPort(); }
const controller::NodeServerConnection& getConnection() const { return mConnection; }
@@ -43,4 +43,4 @@ namespace model {
}
-#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_H
\ No newline at end of file
+#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_H
diff --git a/login_server/src/cpp/model/hedera/TransactionBody.h b/login_server/src/cpp/model/hedera/TransactionBody.h
index b9c25d0c4..c9975a42f 100644
--- a/login_server/src/cpp/model/hedera/TransactionBody.h
+++ b/login_server/src/cpp/model/hedera/TransactionBody.h
@@ -17,7 +17,7 @@
#include "ConsensusCreateTopic.h"
#include "ConsensusSubmitMessage.h"
-#include "../../proto/hedera/TransactionBody.pb.h"
+#include "proto/hedera/TransactionBody.pb.h"
namespace model {
namespace hedera {
@@ -44,7 +44,7 @@ namespace model {
bool setCryptoCreate(CryptoCreateTransaction& cryptoCreateTransaction);
bool setCreateTopic(ConsensusCreateTopic& consensusCreateTopicTransaction);
bool setConsensusSubmitMessage(ConsensusSubmitMessage& consensusSubmitMessageTransaction);
- //bool
+ //bool
inline const proto::TransactionBody* getProtoTransactionBody() const { return &mTransactionBody; }
inline std::string getConnectionString() const { return mConnection.getUriWithPort(); }
@@ -54,7 +54,7 @@ namespace model {
void updateTimestamp();
protected:
-
+
proto::TransactionBody mTransactionBody;
controller::NodeServerConnection mConnection;
bool mHasBody;
@@ -64,4 +64,4 @@ namespace model {
}
-#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_BODY_H
\ No newline at end of file
+#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_BODY_H
diff --git a/login_server/src/cpp/model/hedera/TransactionGetReceiptQuery.h b/login_server/src/cpp/model/hedera/TransactionGetReceiptQuery.h
index bf035a941..725f6b33e 100644
--- a/login_server/src/cpp/model/hedera/TransactionGetReceiptQuery.h
+++ b/login_server/src/cpp/model/hedera/TransactionGetReceiptQuery.h
@@ -2,7 +2,7 @@
#define GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_QUERY_H
#include "QueryHeader.h"
-#include "../../proto/hedera/TransactionGetReceipt.pb.h"
+#include "proto/hedera/TransactionGetReceipt.pb.h"
namespace model {
namespace hedera {
@@ -19,11 +19,11 @@ namespace model {
protected:
Poco::AutoPtr mQueryHeader;
proto::TransactionGetReceiptQuery mProtoReceiptQuery;
-
+
};
}
}
-#endif //GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_QUERY_H
\ No newline at end of file
+#endif //GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_QUERY_H
diff --git a/login_server/src/cpp/model/hedera/TransactionId.h b/login_server/src/cpp/model/hedera/TransactionId.h
index dcc877271..3f8c5114b 100644
--- a/login_server/src/cpp/model/hedera/TransactionId.h
+++ b/login_server/src/cpp/model/hedera/TransactionId.h
@@ -10,7 +10,7 @@
*
*/
-#include "../../proto/hedera/BasicTypes.pb.h"
+#include "proto/hedera/BasicTypes.pb.h"
#include "Poco/JSON/Object.h"
@@ -26,7 +26,7 @@ namespace model {
Poco::JSON::Object::Ptr convertToJSON();
- protected:
+ protected:
Poco::Timestamp mTransactionValidStart;
union {
struct {
@@ -41,4 +41,4 @@ namespace model {
}
-#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_ID_H
\ No newline at end of file
+#endif //_GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_ID_H
diff --git a/login_server/src/cpp/model/hedera/TransactionRecord.h b/login_server/src/cpp/model/hedera/TransactionRecord.h
index d14f42303..15ec1c4b3 100644
--- a/login_server/src/cpp/model/hedera/TransactionRecord.h
+++ b/login_server/src/cpp/model/hedera/TransactionRecord.h
@@ -1,11 +1,11 @@
#ifndef __GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_RECORD_H
#define __GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_RECORD_H
-#include "../../proto/hedera/TransactionRecord.pb.h"
+#include "proto/hedera/TransactionRecord.pb.h"
namespace model
{
- namespace hedera
+ namespace hedera
{
class TransactionRecord
{
diff --git a/login_server/src/cpp/model/hedera/TransactionResponse.h b/login_server/src/cpp/model/hedera/TransactionResponse.h
index 325cbe73f..2f6293191 100644
--- a/login_server/src/cpp/model/hedera/TransactionResponse.h
+++ b/login_server/src/cpp/model/hedera/TransactionResponse.h
@@ -1,7 +1,7 @@
#ifndef __GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_RESPONSE_H
#define __GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_RESPONSE_H
-#include "../../proto/hedera/TransactionResponse.pb.h"
+#include "proto/hedera/TransactionResponse.pb.h"
#include "Poco/Types.h"
namespace model {
@@ -27,4 +27,4 @@ namespace model {
-#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_RESPONSE_H
\ No newline at end of file
+#endif //__GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_RESPONSE_H
diff --git a/login_server/src/cpp/tasks/CPUShedulerThread.cpp b/login_server/src/cpp/tasks/CPUShedulerThread.cpp
index 9529b536f..710adc413 100644
--- a/login_server/src/cpp/tasks/CPUShedulerThread.cpp
+++ b/login_server/src/cpp/tasks/CPUShedulerThread.cpp
@@ -32,6 +32,8 @@ namespace UniLib {
int CPUShedulerThread::ThreadFunction()
{
+ Poco::Logger& errorLog = Poco::Logger::get("errorLog");
+ static const char* function_name = "CPUShedulerThread::ThreadFunction";
while(!mWaitingTask.isNull())
{
@@ -53,7 +55,15 @@ namespace UniLib {
#endif
}
catch (Poco::NullPointerException& ex) {
- printf("[CPUShedulerThread::ThreadFunction] Null Pointer Exception for Task type: %s\n", mWaitingTask->getResourceType());
+ //printf("[CPUShedulerThread::ThreadFunction] Null Pointer Exception for Task type: %s\n", mWaitingTask->getResourceType());
+ errorLog.error("[%s] Null Pointer Exception for Task type %s: %s", function_name, mWaitingTask->getResourceType(), ex.displayText());
+ }
+ catch (Poco::Exception& ex) {
+ errorLog.error("[%s] Exception for Task type %s: %s", function_name, mWaitingTask->getResourceType(), ex.displayText());
+ }
+ catch (std::exception& ex) {
+ std::string exception_message = ex.what();
+ errorLog.error("[%s] std::exception for task type %s: %s", function_name, mWaitingTask->getResourceType(), exception_message);
}
mWaitingTask = mParent->getNextUndoneTask(this);
diff --git a/login_server/src/cpp/test/controller/TestHederaAccount.cpp b/login_server/src/cpp/test/controller/TestHederaAccount.cpp
index 772377d2e..aaeaea723 100644
--- a/login_server/src/cpp/test/controller/TestHederaAccount.cpp
+++ b/login_server/src/cpp/test/controller/TestHederaAccount.cpp
@@ -1,12 +1,12 @@
#include "TestHederaAccount.h"
-#include "../SingletonManager/ConnectionManager.h"
+#include "../../SingletonManager/ConnectionManager.h"
namespace controller {
void TestHederaAccount::SetUp()
{
-
+
}
-
+
TEST_F(TestHederaAccount, TestPick) {
auto hedera_account = controller::HederaAccount::pick(ServerConfig::HEDERA_TESTNET, false);
EXPECT_FALSE(hedera_account.isNull());
diff --git a/login_server/src/cpp/test/controller/TestHederaAccount.h b/login_server/src/cpp/test/controller/TestHederaAccount.h
index 7e8e7843a..721ba17e8 100644
--- a/login_server/src/cpp/test/controller/TestHederaAccount.h
+++ b/login_server/src/cpp/test/controller/TestHederaAccount.h
@@ -1,6 +1,6 @@
#include "gtest/gtest.h"
-#include "../controller/HederaAccount.h"
+#include "../../controller/HederaAccount.h"
namespace controller {
@@ -10,4 +10,4 @@ namespace controller {
void SetUp() override;
};
-}
\ No newline at end of file
+}
diff --git a/login_server/src/cpp/test/controller/TestHederaId.cpp b/login_server/src/cpp/test/controller/TestHederaId.cpp
index c2fed10dd..d08dc7e59 100644
--- a/login_server/src/cpp/test/controller/TestHederaId.cpp
+++ b/login_server/src/cpp/test/controller/TestHederaId.cpp
@@ -1,5 +1,5 @@
#include "TestHederaId.h"
-#include "../SingletonManager/ConnectionManager.h"
+#include "../../SingletonManager/ConnectionManager.h"
namespace controller {
void TestHederaId::SetUp()
diff --git a/login_server/src/cpp/test/controller/TestHederaId.h b/login_server/src/cpp/test/controller/TestHederaId.h
index b6e4b574e..e19b56862 100644
--- a/login_server/src/cpp/test/controller/TestHederaId.h
+++ b/login_server/src/cpp/test/controller/TestHederaId.h
@@ -1,6 +1,6 @@
#include "gtest/gtest.h"
-#include "../controller/HederaId.h"
+#include "../../controller/HederaId.h"
namespace controller {
@@ -10,4 +10,4 @@ namespace controller {
void SetUp() override;
};
-}
\ No newline at end of file
+}
diff --git a/login_server/src/cpp/test/crypto/TestAuthenticatedEncryption.cpp b/login_server/src/cpp/test/crypto/TestAuthenticatedEncryption.cpp
index e863e773d..6c292869a 100644
--- a/login_server/src/cpp/test/crypto/TestAuthenticatedEncryption.cpp
+++ b/login_server/src/cpp/test/crypto/TestAuthenticatedEncryption.cpp
@@ -5,7 +5,7 @@
#include "../../lib/Profiler.h"
#include "../../lib/DataTypeConverter.h"
-#include "../ServerConfig.h"
+#include "../../ServerConfig.h"
void TestAuthenticatedEncryption::SetUp()
{
@@ -39,4 +39,4 @@ TEST_F(TestAuthenticatedEncryption, encryptDecryptTest) {
EXPECT_EQ(std::string((const char*)*decrypted_message, decrypted_message->size()), test_message);
// */
-}
\ No newline at end of file
+}
diff --git a/login_server/src/cpsp/resetPassword.cpsp b/login_server/src/cpsp/resetPassword.cpsp
index 3f90daf2d..393b5cf53 100644
--- a/login_server/src/cpsp/resetPassword.cpsp
+++ b/login_server/src/cpsp/resetPassword.cpsp
@@ -78,7 +78,7 @@ enum PageState {
// send reset password email
int result = 0;
if(user_exist) {
- result = session->sendResetPasswordEmail(user, sendUserEmail, getBaseUrl());
+ result = session->sendResetPasswordEmail(user, sendUserEmail, ServerConfig::g_serverPath + "/checkEmail");
}
if(2 == result) {
diff --git a/login_server/src/cpsp/userUpdatePassword.cpsp b/login_server/src/cpsp/userUpdatePassword.cpsp
index 6987c4c81..1d7ed1d44 100644
--- a/login_server/src/cpsp/userUpdatePassword.cpsp
+++ b/login_server/src/cpsp/userUpdatePassword.cpsp
@@ -29,9 +29,12 @@ enum PageState {
if(!form.empty()) {
auto pwd = form.get("register-password", "");
if(pwd != "") {
+ if(!mSession->getLanguageCatalog()) {
+ mSession->setLanguage(LANG_EN);
+ }
if(pwd != form.get("register-password2", "")) {
mSession->addError(new Error("Passwort", "Passwörter sind nicht identisch."), false);
- } else if(SessionManager::getInstance()->checkPwdValidation(pwd, mSession)) {
+ } else if(SessionManager::getInstance()->checkPwdValidation(pwd, mSession, mSession->getLanguageCatalog())) {
auto sessionState = mSession->getSessionState();
if(user->setNewPassword(pwd) >= 0) {
diff --git a/login_server/unix_parse_proto.sh b/login_server/unix_parse_proto.sh
deleted file mode 100755
index 43fdc3a14..000000000
--- a/login_server/unix_parse_proto.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-if [ ! -d "./src/cpp/proto" ] ; then
- mkdir ./src/cpp/proto
-fi
-if [ ! -d "./src/cpp/proto/gradido" ] ; then
- mkdir ./src/cpp/proto/gradido
-fi
-PROTOC_PATH=./build/bin
-CPP_PLUGIN_PATH=./build/bin
-$PROTOC_PATH/protoc --cpp_out=./src/cpp/proto --proto_path=./src/proto ./src/proto/gradido/*.proto
-
-if [ ! -d "./src/cpp/proto/hedera" ] ; then
- mkdir ./src/cpp/proto/hedera
-fi
-
-GOOGLE_PROTOBUF_INCLUDES=./dependencies/grpc/third_party/protobuf/src
-$PROTOC_PATH/protoc --plugin=protoc-gen-grpc=$CPP_PLUGIN_PATH/grpc_cpp_plugin --cpp_out=./src/cpp/proto/hedera --grpc_out=./src/cpp/proto/hedera --proto_path=$GOOGLE_PROTOBUF_INCLUDES --proto_path=./src/proto/hedera/hedera-protobuf/src/main/proto ./src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
-
-
diff --git a/login_server/windows_parse_proto.sh b/login_server/windows_parse_proto.sh
deleted file mode 100644
index 90497e6b8..000000000
--- a/login_server/windows_parse_proto.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-if [ ! -d "./src/cpp/proto" ] ; then
- mkdir ./src/cpp/proto
-fi
-if [ ! -d "./src/cpp/proto/gradido" ] ; then
- mkdir ./src/cpp/proto/gradido
-fi
-PROTOC_PATH=build/bin
-CPP_PLUGIN_PATH=build/bin
-$PROTOC_PATH/protoc.exe --cpp_out=./src/cpp/proto --proto_path=./src/proto ./src/proto/gradido/*.proto
-
-if [ ! -d "./src/cpp/proto/hedera" ] ; then
- mkdir ./src/cpp/proto/hedera
-fi
-
-GOOGLE_PROTOBUF_INCLUDES=./dependencies/grpc/third_party/protobuf/src
-$PROTOC_PATH/protoc.exe --plugin=protoc-gen-grpc=$CPP_PLUGIN_PATH/grpc_cpp_plugin.exe --cpp_out=./src/cpp/proto/hedera --grpc_out=./src/cpp/proto/hedera --proto_path=$GOOGLE_PROTOBUF_INCLUDES --proto_path=./src/proto/hedera/hedera-protobuf/src/main/proto ./src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
-
-
diff --git a/mariadb/setup_dbs_different_user.sh b/mariadb/setup_dbs_different_user.sh
index 604276ef3..e4c0820f7 100755
--- a/mariadb/setup_dbs_different_user.sh
+++ b/mariadb/setup_dbs_different_user.sh
@@ -3,12 +3,12 @@ COLOR_GREEN="\033[0;32m"
COLOR_YELLOW="\e[33m"
COLOR_NONE="\033[0m"
-LOGIN_DB_USER=gradido_login
-LOGIN_DB_NAME=gradido_login
+LOGIN_DB_USER=gradido_login_live
+LOGIN_DB_NAME=gradido_login_live
LOGIN_DB_PASSWD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo);
-COMMUNITY_DB_USER=gradido_community
-COMMUNITY_DB_NAME=gradido_community
+COMMUNITY_DB_USER=gradido_community_live
+COMMUNITY_DB_NAME=gradido_community_live
COMMUNITY_DB_PASSWD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo);
# create table
diff --git a/package.json b/package.json
index 593a21754..0ebef23ff 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gradido",
- "version": "0.9.4",
+ "version": "1.0.1",
"description": "Gradido",
"main": "index.js",
"repository": "git@github.com:gradido/gradido.git",