mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
commit
d2ca4fc42e
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
*.log
|
||||
/node_modules/*
|
||||
/node_modules/*
|
||||
.vscode
|
||||
|
||||
10
CHANGELOG.md
10
CHANGELOG.md
@ -4,8 +4,18 @@ 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).
|
||||
|
||||
#### [0.9.4](https://github.com/gradido/gradido/compare/0.9.3...0.9.4)
|
||||
|
||||
- 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)
|
||||
- build login-server on docker-compose up in a docker volume so it rebuild only neccessary parts if some c++ files have changed [`0da5279`](https://github.com/gradido/gradido/commit/0da527917523530186e6effe63dc001fc99bd3e3)
|
||||
|
||||
#### [0.9.3](https://github.com/gradido/gradido/compare/0.9.2...0.9.3)
|
||||
|
||||
> 30 March 2021
|
||||
|
||||
- new version 0.9.3 [`#110`](https://github.com/gradido/gradido/pull/110)
|
||||
- feat: Frontend tests for Content Footer [`#102`](https://github.com/gradido/gradido/pull/102)
|
||||
- add check session state json function and doc [`#96`](https://github.com/gradido/gradido/pull/96)
|
||||
- activity page stap 2 [`#86`](https://github.com/gradido/gradido/pull/86)
|
||||
|
||||
@ -39,32 +39,143 @@ class StateBalancesController extends AppController
|
||||
$this->set(compact('stateBalances'));
|
||||
}
|
||||
|
||||
private function updateBalances($state_user_id)
|
||||
private function updateBalances($stateUserId)
|
||||
{
|
||||
$state_balances = $this->StateBalances->find('all')->where(['state_user_id' => $state_user_id]);
|
||||
if($state_balances->count() == 1) {
|
||||
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
|
||||
$state_user_transactions = $stateUserTransactionsTable
|
||||
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
|
||||
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
|
||||
// info: cakephp use lazy loading, query will be executed later only if needed
|
||||
$state_balances = $this->StateBalances->find('all')->where(['state_user_id' => $stateUserId]);
|
||||
$state_user_transactions = $stateUserTransactionsTable
|
||||
->find('all')
|
||||
->where(['state_user_id' => $state_user_id])
|
||||
->where(['state_user_id' => $stateUserId])
|
||||
->order(['transaction_id ASC'])
|
||||
->contain(['']);
|
||||
if($state_user_transactions->count() == 0){
|
||||
return;
|
||||
}
|
||||
$last_state_user_transaction = $state_user_transactions->last();
|
||||
$last_transaction = $this->StateBalance->newEntity();
|
||||
$last_transaction->amount = $last_state_user_transaction->balance;
|
||||
$last_transaction->record_date = $last_state_user_transaction->balance_date;
|
||||
// if entrys are nearly the same, we don't need doing anything
|
||||
if(abs($last_transaction->decay - $state_balances->decay) < 100) {
|
||||
return;
|
||||
}
|
||||
foreach($state_user_transactions as $state_user_transaction) {
|
||||
|
||||
}
|
||||
|
||||
->contain(false);
|
||||
|
||||
if(!$state_user_transactions) {
|
||||
//debug($state_user_transactions);
|
||||
return true;
|
||||
}
|
||||
|
||||
// first: decide what todo
|
||||
$create_state_balance = false;
|
||||
$recalculate_state_user_transactions_balance = false;
|
||||
$clear_state_balance = false;
|
||||
$update_state_balance = false;
|
||||
if($state_balances->count() == 0) {
|
||||
$create_state_balance = true;
|
||||
}
|
||||
if($state_balances->count() > 1) {
|
||||
$clear_state_balance = true;
|
||||
$create_state_balance = true;
|
||||
}
|
||||
if($state_balances->count() == 1) {
|
||||
if($state_user_transactions->count() == 0){
|
||||
$clear_state_balance = true;
|
||||
} else {
|
||||
$last_state_user_transaction = $state_user_transactions->last();
|
||||
$last_transaction = $this->StateBalances->newEntity();
|
||||
$last_transaction->amount = $last_state_user_transaction->balance;
|
||||
$last_transaction->record_date = $last_state_user_transaction->balance_date;
|
||||
// if entrys are nearly the same, we don't need doing anything
|
||||
if(abs($last_transaction->decay - $state_balances->first()->decay) > 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->balance <= 0) {
|
||||
$recalculate_state_user_transactions_balance = true;
|
||||
if(!$create_state_balance) {
|
||||
$update_state_balance = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// second: do what is needed
|
||||
if($clear_state_balance) {
|
||||
$this->StateBalances->deleteAll(['state_user_id' => $stateUserId]);
|
||||
}
|
||||
|
||||
$transaction_ids = [];
|
||||
if($recalculate_state_user_transactions_balance) {
|
||||
$state_user_transactions_array = $state_user_transactions->toArray();
|
||||
foreach($state_user_transactions_array as $i => $state_user_transaction) {
|
||||
$transaction_ids[$state_user_transaction->transaction_id] = $i;
|
||||
}
|
||||
|
||||
$transactions = $transactionsTable
|
||||
->find('all')
|
||||
->where(['id IN' => array_keys($transaction_ids)])
|
||||
->contain(['TransactionCreations', 'TransactionSendCoins']);
|
||||
|
||||
$balance_cursor = $this->StateBalances->newEntity();
|
||||
$i = 0;
|
||||
foreach($transactions as $transaction) {
|
||||
if($transaction->transaction_type_id > 2) {
|
||||
continue;
|
||||
}
|
||||
$amount_date = null;
|
||||
$amount = 0;
|
||||
|
||||
if($transaction->transaction_type_id == 1) {
|
||||
$temp = $transaction->transaction_creations[0];
|
||||
|
||||
$balance_temp = $this->StateBalances->newEntity();
|
||||
$balance_temp->amount = $temp->amount;
|
||||
$balance_temp->record_date = $temp->target_date;
|
||||
|
||||
$amount = $balance_temp->partDecay($transaction->received);
|
||||
$amount_date = $transaction->received;
|
||||
//$amount_date =
|
||||
} else if($transaction->transaction_type_id == 2) {
|
||||
$temp = $transaction->transaction_send_coins[0];
|
||||
$amount = intval($temp->amount);
|
||||
// reverse if sender
|
||||
if($stateUserId == $temp->state_user_id) {
|
||||
$amount *= -1.0;
|
||||
}
|
||||
$amount_date = $transaction->received;
|
||||
}
|
||||
if($i == 0) {
|
||||
$balance_cursor->amount = $amount;
|
||||
} else {
|
||||
$balance_cursor->amount = $balance_cursor->partDecay($amount_date) + $amount;
|
||||
}
|
||||
$balance_cursor->record_date = $amount_date;
|
||||
$state_user_transaction_index = $transaction_ids[$transaction->id];
|
||||
$state_user_transactions_array[$state_user_transaction_index]->balance = $balance_cursor->amount;
|
||||
$state_user_transactions_array[$state_user_transaction_index]->balance_date = $balance_cursor->record_date;
|
||||
$i++;
|
||||
}
|
||||
$results = $stateUserTransactionsTable->saveMany($state_user_transactions_array);
|
||||
$errors = [];
|
||||
foreach($results as $i => $result) {
|
||||
if(!$result) {
|
||||
$errors[$i] = $state_user_transactions_array[$i]->getErrors();
|
||||
}
|
||||
}
|
||||
if(count($errors)) {
|
||||
return ['success' => false, 'error' => 'error saving one ore more state user transactions', 'details' => $errors];
|
||||
}
|
||||
}
|
||||
$state_balance = null;
|
||||
if($update_state_balance) {
|
||||
$state_balance = $state_balances->first();
|
||||
}
|
||||
else if($create_state_balance) {
|
||||
$state_balance = $this->StateBalances->newEntity();
|
||||
$state_balance->state_user_id = $stateUserId;
|
||||
}
|
||||
if($state_balance) {
|
||||
$state_balance->amount = $state_user_transactions->last()->balance;
|
||||
$state_balance->record_date = $state_user_transactions->last()->balance_date;
|
||||
if(!$this->StateBalances->save($state_balance)) {
|
||||
return ['success' => false, 'error' => 'error saving state balance', 'details' => $state_balance->getErrors()];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function overview()
|
||||
@ -82,7 +193,9 @@ class StateBalancesController extends AppController
|
||||
if ($result !== true) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$user = $session->read('StateUser');
|
||||
$this->updateBalances($user['id']);
|
||||
// sendRequestGDT
|
||||
// listPerEmailApi
|
||||
|
||||
@ -214,6 +327,7 @@ class StateBalancesController extends AppController
|
||||
}
|
||||
$session = $this->getRequest()->getSession();
|
||||
$user = $session->read('StateUser');
|
||||
$this->updateBalances($user['id']);
|
||||
|
||||
$public_key_bin = hex2bin($user['public_hex']);
|
||||
$stateUserQuery = $this->StateBalances->StateUsers
|
||||
|
||||
@ -69,14 +69,14 @@ class StateUsersController extends AppController
|
||||
$this->set(compact('stateUsers'));
|
||||
}
|
||||
|
||||
public function listIdentHashes()
|
||||
/*public function listIdentHashes()
|
||||
{
|
||||
$stateUsers = $this->StateUsers->find('all')->toArray();
|
||||
foreach ($stateUsers as $i => $user) {
|
||||
$stateUsers[$i]->identHash = TransactionCreation::DRMakeStringHash($user->email);
|
||||
}
|
||||
$this->set('stateUsers', $stateUsers);
|
||||
}
|
||||
}*/
|
||||
|
||||
public function search()
|
||||
{
|
||||
|
||||
@ -54,12 +54,12 @@ class TransactionCreationsController extends AppController
|
||||
];
|
||||
$transactionCreations = $this->paginate($this->TransactionCreations);
|
||||
$identHashes = [];
|
||||
foreach ($transactionCreations as $creation) {
|
||||
/*foreach ($transactionCreations as $creation) {
|
||||
$identHash = TransactionCreation::DRMakeStringHash($creation->state_user->email);
|
||||
$identHashes[$creation->state_user->id] = $identHash;
|
||||
}
|
||||
}*/
|
||||
|
||||
$this->set(compact('transactionCreations', 'identHashes'));
|
||||
//$this->set(compact('transactionCreations', 'identHashes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ class TransactionCreationsController extends AppController
|
||||
|
||||
if (count($receiverProposal) > $receiverIndex) {
|
||||
$pubKeyHex = $receiverProposal[$receiverIndex]['key'];
|
||||
$identHash = TransactionCreation::DRMakeStringHash($receiverProposal[$receiverIndex]['email']);
|
||||
//$identHash = TransactionCreation::DRMakeStringHash($receiverProposal[$receiverIndex]['email']);
|
||||
}
|
||||
$builderResult = TransactionCreation::build(
|
||||
$amountCent,
|
||||
@ -369,7 +369,20 @@ class TransactionCreationsController extends AppController
|
||||
$pendings[$id] = $localAmountCent;
|
||||
}
|
||||
$pubKeyHex = bin2hex(stream_get_contents($receiverUser->public_key));
|
||||
$identHash = TransactionCreation::DRMakeStringHash($receiverUser->email);
|
||||
$requestAnswear = $this->JsonRequestClient->sendRequest(json_encode([
|
||||
'session_id' => $session->read('session_id'),
|
||||
'email' => $receiverUser->email,
|
||||
'ask' => ['user.identHash']
|
||||
]), '/getUserInfos');
|
||||
|
||||
$identHash = 0;
|
||||
if('success' == $requestAnswear['state'] && 'success' == $requestAnswear['data']['state']) {
|
||||
$identHash = $requestAnswear['data']['userData']['identHash'];
|
||||
} else {
|
||||
$this->Flash->error(__('Error by requesting LoginServer, please try again'));
|
||||
}
|
||||
|
||||
//$identHash = TransactionCreation::DRMakeStringHash($receiverUser->email);
|
||||
$localTargetDateFrozen = FrozenDate::now();
|
||||
$localTargetDateFrozen = $localTargetDateFrozen
|
||||
->year($localTargetDate['year'])
|
||||
|
||||
@ -57,7 +57,8 @@ class StateBalance extends Entity
|
||||
if($decay_duration === 0) {
|
||||
return $this->amount;
|
||||
}
|
||||
return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
return $this->amount;
|
||||
//return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
|
||||
}
|
||||
public function partDecay($target_date)
|
||||
@ -67,7 +68,8 @@ class StateBalance extends Entity
|
||||
if($decay_duration <= 0) {
|
||||
return $this->amount;
|
||||
}
|
||||
return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
return 0;
|
||||
//return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
}
|
||||
|
||||
public function decayDuration($target_date)
|
||||
|
||||
@ -63,24 +63,6 @@ class TransactionCreation extends TransactionBase {
|
||||
return ['state' => 'success', 'transactionBody' => $transactionBody];
|
||||
}
|
||||
|
||||
static protected function DRHashRotateLeft( $hash, $rotateBy )
|
||||
{
|
||||
return ($hash<<$rotateBy)|($hash>>(32-$rotateBy));
|
||||
}
|
||||
|
||||
static public function DRMakeStringHash($str)
|
||||
{
|
||||
$ret = 0;
|
||||
|
||||
if( $str )
|
||||
{
|
||||
for ($i=0; $i < strlen($str); $i++)
|
||||
{
|
||||
$ret = TransactionCreation::DRHashRotateLeft($ret, 7) + ord($str{$i});
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getAmount() {
|
||||
return $this->protoTransactionCreation->getReceiverAmount()->getAmount();
|
||||
@ -272,7 +254,7 @@ class TransactionCreation extends TransactionBase {
|
||||
->setSubject(__('Gradido Schöpfung erhalten'))
|
||||
->send();
|
||||
} catch(Exception $e) {
|
||||
$this->addError('TransactionCreation::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
// $this->addError('TransactionCreation::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -303,7 +285,7 @@ class TransactionCreation extends TransactionBase {
|
||||
|
||||
// intval
|
||||
//$protoCreation->setIdentHash(intval($identHashBytes));
|
||||
$protoCreation->setIdentHash(self::DRMakeStringHash($stateUser->email));
|
||||
//$protoCreation->setIdentHash(self::DRMakeStringHash($stateUser->email));
|
||||
return new TransactionCreation($protoCreation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,8 @@ class TransactionTransfer extends TransactionBase {
|
||||
foreach($sigPairs as $sigPair) {
|
||||
//echo 'sig Pair: '; var_dump($sigPair); echo "<br>";
|
||||
$pubkey = bin2hex($sigPair->getPubKey());
|
||||
$hash = TransactionCreation::DRMakeStringHash($pubkey);
|
||||
//$hash = TransactionCreation::DRMakeStringHash($pubkey);
|
||||
$hash = $pubkey;
|
||||
if(!isset($sigPubHexs[$hash])) {
|
||||
$sigPubHexs[$hash] = [$pubkey];
|
||||
} else {
|
||||
@ -100,7 +101,8 @@ class TransactionTransfer extends TransactionBase {
|
||||
return false;
|
||||
}
|
||||
// check if signature exist for sender
|
||||
$hash = TransactionCreation::DRMakeStringHash($senderPublicHex);
|
||||
//$hash = TransactionCreation::DRMakeStringHash($senderPublicHex);
|
||||
$hash = $senderPublicHex;
|
||||
if(!isset($sigPubHexs[$hash]) || in_array($senderPublicHex, $sigPubHexs[$hash]) === FALSE) {
|
||||
$this->addError($functionName, 'missing signature for sender');
|
||||
return false;
|
||||
@ -253,7 +255,7 @@ class TransactionTransfer extends TransactionBase {
|
||||
->setSubject(__('Gradidos erhalten'))
|
||||
->send();
|
||||
} catch(Exception $e) {
|
||||
$this->addError('TransactionTransfer::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
//$this->addError('TransactionTransfer::sendNotificationEmail', 'error sending notification email: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -1,65 +1,82 @@
|
||||
version: "3.4"
|
||||
|
||||
services:
|
||||
########################################################
|
||||
# FRONTEND #############################################
|
||||
########################################################
|
||||
frontend:
|
||||
image: gradido/frontend:development
|
||||
build:
|
||||
target: development
|
||||
environment:
|
||||
- NODE_ENV="development"
|
||||
# - DEBUG=true
|
||||
- NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/`
|
||||
volumes:
|
||||
# This makes sure the docker container has its own node modules.
|
||||
# Therefore it is possible to have a different node version on the host machine
|
||||
- frontend_node_modules:/app/node_modules
|
||||
# bind the local folder to the docker to allow live reload
|
||||
- ./frontend:/app
|
||||
|
||||
#########################################################
|
||||
## LOGIN SERVER #########################################
|
||||
#########################################################
|
||||
login-server:
|
||||
build:
|
||||
target: login_server_debug
|
||||
dockerfile: Dockerfile.debug
|
||||
security_opt:
|
||||
- seccomp:unconfined
|
||||
cap_add:
|
||||
- SYS_PTRACE
|
||||
volumes:
|
||||
- ./logs:/var/log/grd_login
|
||||
- ./login_server/src:/code/src
|
||||
- login_build:/code/build_vol
|
||||
|
||||
#########################################################
|
||||
## NGINX ################################################
|
||||
#########################################################
|
||||
nginx:
|
||||
volumes:
|
||||
- ./logs:/var/log/nginx
|
||||
|
||||
#########################################################
|
||||
## PHPMYADMIN ###########################################
|
||||
#########################################################
|
||||
phpmyadmin:
|
||||
image: phpmyadmin
|
||||
container_name: phpmyadmin
|
||||
environment:
|
||||
- PMA_ARBITRARY=1
|
||||
#restart: always
|
||||
ports:
|
||||
- 8074:80
|
||||
networks:
|
||||
- internal-net
|
||||
- external-net
|
||||
volumes:
|
||||
- /sessions
|
||||
|
||||
volumes:
|
||||
frontend_node_modules:
|
||||
login_build:
|
||||
|
||||
version: "3.4"
|
||||
|
||||
services:
|
||||
########################################################
|
||||
# FRONTEND #############################################
|
||||
########################################################
|
||||
frontend:
|
||||
image: gradido/frontend:development
|
||||
build:
|
||||
target: development
|
||||
environment:
|
||||
- NODE_ENV="development"
|
||||
# - DEBUG=true
|
||||
- NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/`
|
||||
volumes:
|
||||
# This makes sure the docker container has its own node modules.
|
||||
# Therefore it is possible to have a different node version on the host machine
|
||||
- frontend_node_modules:/app/node_modules
|
||||
# bind the local folder to the docker to allow live reload
|
||||
- ./frontend:/app
|
||||
|
||||
#########################################################
|
||||
## LOGIN SERVER #########################################
|
||||
#########################################################
|
||||
login-server:
|
||||
build:
|
||||
target: login_server_debug
|
||||
dockerfile: Dockerfile.debug
|
||||
security_opt:
|
||||
- seccomp:unconfined
|
||||
cap_add:
|
||||
- SYS_PTRACE
|
||||
volumes:
|
||||
- ./logs:/var/log/grd_login
|
||||
- conan:/root/.conan
|
||||
|
||||
#########################################################
|
||||
## NGINX ################################################
|
||||
#########################################################
|
||||
nginx:
|
||||
depends_on:
|
||||
- frontend
|
||||
- community-server
|
||||
- login-server
|
||||
volumes:
|
||||
- ./logs:/var/log/nginx
|
||||
|
||||
#########################################################
|
||||
## PHPMYADMIN ###########################################
|
||||
#########################################################
|
||||
phpmyadmin:
|
||||
image: phpmyadmin
|
||||
container_name: phpmyadmin
|
||||
environment:
|
||||
- PMA_ARBITRARY=1
|
||||
#restart: always
|
||||
ports:
|
||||
- 8074:80
|
||||
networks:
|
||||
- internal-net
|
||||
- external-net
|
||||
volumes:
|
||||
- /sessions
|
||||
|
||||
#########################################################
|
||||
## skeema for updating dbs if changes happend ###########
|
||||
#########################################################
|
||||
skeema:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./skeema/Dockerfile
|
||||
target: skeema_run
|
||||
container_name: skeema
|
||||
depends_on:
|
||||
- mariadb
|
||||
networks:
|
||||
- internal-net
|
||||
|
||||
volumes:
|
||||
frontend_node_modules:
|
||||
conan:
|
||||
|
||||
|
||||
@ -16,8 +16,6 @@ services:
|
||||
target: production
|
||||
networks:
|
||||
- external-net
|
||||
depends_on:
|
||||
- nginx
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
@ -135,4 +133,4 @@ networks:
|
||||
internal: true
|
||||
|
||||
volumes:
|
||||
db_vol:
|
||||
db_vol:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
LOGIN_API_URL=http://localhost/login_api/
|
||||
COMMUNITY_API_STATE_BALANCE_URL=http://localhost/state-balances/
|
||||
COMMUNITY_API_TRANSACTION_CREATION_URL=http://localhost/transaction-creations/
|
||||
COMMUNITY_API_TRANSACTION_CREATION_URL=http://localhost/transaction-creations/
|
||||
VUE_PATH=/vue
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bootstrap-vue-gradido-wallet",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
|
||||
@ -4,6 +4,12 @@ const dotenv = require('dotenv-webpack')
|
||||
function resolveSrc(_path) {
|
||||
return path.join(__dirname, _path)
|
||||
}
|
||||
|
||||
let vue_path = process.env.VUE_PATH
|
||||
if (vue_path == undefined) {
|
||||
vue_path = ''
|
||||
}
|
||||
|
||||
// vue.config.js
|
||||
module.exports = {
|
||||
pluginOptions: {
|
||||
@ -15,6 +21,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
lintOnSave: true,
|
||||
publicPath: vue_path + '/',
|
||||
configureWebpack: {
|
||||
// Set up all the aliases we use in our app.
|
||||
resolve: {
|
||||
@ -28,4 +35,5 @@ module.exports = {
|
||||
// Enable CSS source maps.
|
||||
sourceMap: process.env.NODE_ENV !== 'production',
|
||||
},
|
||||
outputDir: path.resolve(__dirname, './dist' + vue_path),
|
||||
}
|
||||
|
||||
2
gn
2
gn
@ -1 +1 @@
|
||||
Subproject commit a61871987261614102b11ed58791081be1954d3c
|
||||
Subproject commit 5437e2f882c54efe4f501f7cd0d97f53806d0b74
|
||||
@ -11,16 +11,15 @@ using namespace Poco::Data::Keywords;
|
||||
#include "../SingletonManager/ConnectionManager.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../SingletonManager/EmailManager.h"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
#include "../tasks/PrepareEmailTask.h"
|
||||
#include "../tasks/SendEmailTask.h"
|
||||
|
||||
#include "../controller/EmailVerificationCode.h"
|
||||
#include "../model/table/ElopageBuy.h"
|
||||
|
||||
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
|
||||
|
||||
void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
|
||||
@ -277,22 +276,9 @@ int HandleElopageRequestTask::run()
|
||||
saveElopageBuy->scheduleTask(saveElopageBuy);
|
||||
|
||||
// check product id
|
||||
Poco::UInt64 product_id = 0;
|
||||
try {
|
||||
product_id = stoull(mRequestData.get("product[id]", "0"));
|
||||
}
|
||||
catch (const std::invalid_argument& ia) {
|
||||
std::cerr << __FUNCTION__ << "Invalid argument: " << ia.what() << '\n';
|
||||
}
|
||||
catch (const std::out_of_range& oor) {
|
||||
std::cerr << __FUNCTION__ << "Out of Range error: " << oor.what() << '\n';
|
||||
}
|
||||
catch (const std::logic_error & ler) {
|
||||
std::cerr << __FUNCTION__ << "Logical error: " << ler.what() << '\n';
|
||||
}
|
||||
catch (...) {
|
||||
std::cerr << __FUNCTION__ << "Unknown error" << '\n';
|
||||
}
|
||||
unsigned long long product_id = 0;
|
||||
DataTypeConverter::strToInt(mRequestData.get("product[id]", "0"), product_id);
|
||||
|
||||
std::string order_id = mRequestData.get("order_id", "");
|
||||
auto param_error_order_id = new ParamError("HandleElopageRequestTask", "order_id", order_id.data());
|
||||
|
||||
@ -380,56 +366,16 @@ int HandleElopageRequestTask::run()
|
||||
sendErrorsAsEmail();
|
||||
return -4;
|
||||
}
|
||||
auto em = EmailManager::getInstance();
|
||||
if (emailVerification->getModel()->insertIntoDB(false)) {
|
||||
int noEMail = 0;
|
||||
DataTypeConverter::strToInt(mRequestData.get("noEmail", "0"), noEMail);
|
||||
|
||||
// write email verification code into db
|
||||
UniLib::controller::TaskPtr saveEmailVerificationCode(new model::table::ModelInsertTask(emailVerification->getModel(), true));
|
||||
saveEmailVerificationCode->scheduleTask(saveEmailVerificationCode);
|
||||
int noEMail = 0;
|
||||
|
||||
std::string noEmailString = mRequestData.get("noEmail", "0");
|
||||
try {
|
||||
noEMail = stoi(noEmailString);
|
||||
}
|
||||
catch (const std::invalid_argument& ia) {
|
||||
std::cerr << __FUNCTION__ << " Invalid argument: " << ia.what() << ", str: " << noEmailString << '\n';
|
||||
}
|
||||
catch (const std::out_of_range& oor) {
|
||||
std::cerr << __FUNCTION__ << " Out of Range error: " << oor.what() << '\n';
|
||||
}
|
||||
catch (const std::logic_error & ler) {
|
||||
std::cerr << __FUNCTION__ << " Logical error: " << ler.what() << '\n';
|
||||
}
|
||||
catch (...) {
|
||||
std::cerr << __FUNCTION__ << " Unknown error" << '\n';
|
||||
if (noEMail != 1) {
|
||||
em->addEmail(new model::Email(emailVerification, newUser, model::EMAIL_USER_VERIFICATION_CODE));
|
||||
}
|
||||
}
|
||||
|
||||
if (noEMail != 1) {
|
||||
|
||||
// send email to user
|
||||
/*auto message = new Poco::Net::MailMessage;
|
||||
|
||||
message->addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, mEmail));
|
||||
message->setSubject("Gradido: E-Mail Verification");
|
||||
std::stringstream ss;
|
||||
ss << "Hallo " << mFirstName << " " << mLastName << "," << std::endl << std::endl;
|
||||
ss << "Du oder jemand anderes hat sich soeben mit dieser E-Mail Adresse bei Gradido registriert. " << std::endl;
|
||||
ss << "Wenn du es warst, klicke bitte auf den Link: " << ServerConfig::g_serverPath << "/checkEmail/" << emailVerification->getModel()->getCode() << std::endl;
|
||||
//ss << "oder kopiere den Code: " << mEmailVerificationCode << " selbst dort hinein." << std::endl;
|
||||
ss << "oder kopiere den obigen Link in Dein Browserfenster." << std::endl;
|
||||
ss << std::endl;
|
||||
|
||||
ss << "Mit freundlichen " << u8"Grüßen" << std::endl;
|
||||
ss << "Dario, Gradido Server Admin" << std::endl;
|
||||
|
||||
message->addContent(new Poco::Net::StringPartSource(ss.str()));
|
||||
*/
|
||||
//UniLib::controller::TaskPtr sendEmail(new SendEmailTask(message, ServerConfig::g_CPUScheduler, 1));
|
||||
//Email(AutoPtr<controller::EmailVerificationCode> emailVerification, AutoPtr<controller::User> user, EmailType type);
|
||||
UniLib::controller::TaskPtr sendEmail(new SendEmailTask(new model::Email(emailVerification, newUser, model::EMAIL_USER_VERIFICATION_CODE), ServerConfig::g_CPUScheduler, 1));
|
||||
//sendEmail->setParentTaskPtrInArray(prepareEmail, 0);
|
||||
sendEmail->setParentTaskPtrInArray(saveEmailVerificationCode, 0);
|
||||
sendEmail->scheduleTask(sendEmail);
|
||||
}
|
||||
}
|
||||
|
||||
// if errors occured, send via email
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
#include "../SingletonManager/EmailManager.h"
|
||||
#include "../SingletonManager/SingletonTaskObserver.h"
|
||||
|
||||
#include "../tasks/PrepareEmailTask.h"
|
||||
#include "../tasks/SendEmailTask.h"
|
||||
#include "../tasks/SigningTransaction.h"
|
||||
#include "../tasks/AuthenticatedEncryptionCreateKeyTask.h"
|
||||
#include "../tasks/VerificationEmailResendTask.h"
|
||||
@ -348,12 +346,14 @@ bool Session::createUser(const std::string& first_name, const std::string& last_
|
||||
*/
|
||||
//UniLib::controller::TaskPtr sendEmail(new SendEmailTask(message, ServerConfig::g_CPUScheduler, 1));
|
||||
//Email(AutoPtr<controller::EmailVerificationCode> emailVerification, AutoPtr<controller::User> user, EmailType type);
|
||||
UniLib::controller::TaskPtr sendEmail(new SendEmailTask(new model::Email(mEmailVerificationCodeObject, mNewUser, model::EMAIL_USER_VERIFICATION_CODE), ServerConfig::g_CPUScheduler, 1));
|
||||
auto em = EmailManager::getInstance();
|
||||
em->addEmail(new model::Email(mEmailVerificationCodeObject, mNewUser, model::EMAIL_USER_VERIFICATION_CODE));
|
||||
/*UniLib::controller::TaskPtr sendEmail(new SendEmailTask(new model::Email(mEmailVerificationCodeObject, mNewUser, model::EMAIL_USER_VERIFICATION_CODE), ServerConfig::g_CPUScheduler, 1));
|
||||
//sendEmail->setParentTaskPtrInArray(prepareEmail, 0);
|
||||
sendEmail->setParentTaskPtrInArray(writeEmailVerification, 0);
|
||||
sendEmail->setFinishCommand(new SessionStateUpdateCommand(SESSION_STATE_EMAIL_VERIFICATION_SEND, this));
|
||||
sendEmail->scheduleTask(sendEmail);
|
||||
|
||||
*/
|
||||
// write user into db
|
||||
// generate and write email verification into db
|
||||
// send email
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
#include "PrepareEmailTask.h"
|
||||
#include "../lib/Profiler.h"
|
||||
#include "../ServerConfig.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
|
||||
#include "Poco/Net/SSLException.h"
|
||||
|
||||
PrepareEmailTask::PrepareEmailTask(UniLib::controller::CPUSheduler* cpuScheduler)
|
||||
: UniLib::controller::CPUTask(cpuScheduler), mMailClientSession(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PrepareEmailTask::~PrepareEmailTask()
|
||||
{
|
||||
if (mMailClientSession) {
|
||||
delete mMailClientSession;
|
||||
}
|
||||
}
|
||||
|
||||
int PrepareEmailTask::run()
|
||||
{
|
||||
if (ServerConfig::g_disableEmail) return 0;
|
||||
Profiler timeUsed;
|
||||
mMailClientSession = new Poco::Net::SecureSMTPClientSession(ServerConfig::g_EmailAccount.url, ServerConfig::g_EmailAccount.port);
|
||||
mMailClientSession->login();
|
||||
try {
|
||||
mMailClientSession->startTLS(ServerConfig::g_SSL_CLient_Context);
|
||||
mMailClientSession->login(Poco::Net::SMTPClientSession::AUTH_LOGIN, ServerConfig::g_EmailAccount.username, ServerConfig::g_EmailAccount.password);
|
||||
} catch(Poco::Net::SSLException& ex) {
|
||||
printf("[PrepareEmailTask] ssl certificate error: %s\nPlease make sure you have cacert.pem (CA/root certificates) next to binary from https://curl.haxx.se/docs/caextract.html\n", ex.displayText().data());
|
||||
return -1;
|
||||
}
|
||||
|
||||
//printf("[PrepareEmailTask] time: %s\n", timeUsed.string().data());
|
||||
/*
|
||||
session.login();
|
||||
session.startTLS(pContext);
|
||||
if (!username.empty())
|
||||
{
|
||||
session.login(SMTPClientSession::AUTH_LOGIN, username, password);
|
||||
}
|
||||
session.sendMessage(message);
|
||||
session.close();
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PrepareEmailTask::send(Poco::Net::MailMessage* message)
|
||||
{
|
||||
if (ServerConfig::g_disableEmail) return 0;
|
||||
|
||||
auto er = ErrorManager::getInstance();
|
||||
try {
|
||||
mMailClientSession->sendMessage(*message);
|
||||
mMailClientSession->close();
|
||||
}
|
||||
catch (Poco::Exception& exc) {
|
||||
er->addError(new ParamError("PrepareEmailTask::send", "error sending email", exc.displayText().data()));
|
||||
printf("[PrepareEmailTask::%s] error sending email: %s\n", __FUNCTION__, exc.displayText().data());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
#ifndef GRADIDO_LOGIN_SERVER_TASKS_PREPAIRE_EMAIL_TASK_INCLUDE
|
||||
#define GRADIDO_LOGIN_SERVER_TASKS_PREPAIRE_EMAIL_TASK_INCLUDE
|
||||
|
||||
#include "CPUTask.h"
|
||||
#include "Poco/Net/SecureSMTPClientSession.h"
|
||||
|
||||
|
||||
|
||||
class PrepareEmailTask : public UniLib::controller::CPUTask
|
||||
{
|
||||
public:
|
||||
PrepareEmailTask(UniLib::controller::CPUSheduler* cpuScheduler);
|
||||
virtual ~PrepareEmailTask();
|
||||
|
||||
virtual int run();
|
||||
int send(Poco::Net::MailMessage* message);
|
||||
virtual const char* getResourceType() const { return "PrepareEmailTask"; };
|
||||
protected:
|
||||
|
||||
private:
|
||||
Poco::Net::SecureSMTPClientSession* mMailClientSession;
|
||||
};
|
||||
|
||||
|
||||
#endif //GRADIDO_LOGIN_SERVER_TASKS_PREPAIRE_EMAIL_TASK_INCLUDE
|
||||
@ -1,64 +0,0 @@
|
||||
#include "SendEmailTask.h"
|
||||
#include "PrepareEmailTask.h"
|
||||
#include "../lib/Profiler.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
#include "../SingletonManager/EmailManager.h"
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
#include "Poco/Net/MediaType.h"
|
||||
|
||||
SendEmailTask::SendEmailTask(Poco::Net::MailMessage* mailMessage, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount/* = 0*/)
|
||||
: UniLib::controller::CPUTask(cpuScheduler, additionalTaskDependenceCount+1), mMailMessage(mailMessage), mEmail(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SendEmailTask::SendEmailTask(model::Email*email, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount/* = 0*/)
|
||||
: UniLib::controller::CPUTask(cpuScheduler, additionalTaskDependenceCount), mMailMessage(nullptr), mEmail(email)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SendEmailTask::~SendEmailTask()
|
||||
{
|
||||
if (mMailMessage) {
|
||||
delete mMailMessage;
|
||||
mMailMessage = nullptr;
|
||||
}
|
||||
if (mEmail) {
|
||||
delete mEmail;
|
||||
mEmail = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int SendEmailTask::run()
|
||||
{
|
||||
if(ServerConfig::g_disableEmail) return 0;
|
||||
|
||||
Profiler timeUsed;
|
||||
auto er = ErrorManager::getInstance();
|
||||
auto parent = getParent(0);
|
||||
|
||||
if (mMailMessage) {
|
||||
|
||||
if (strcmp(parent->getResourceType(), "PrepareEmailTask") != 0) {
|
||||
er->addError(new Error("SendEmailTask", "first parent isn't PrepareEmailTask"));
|
||||
er->sendErrorsAsEmail();
|
||||
return -1;
|
||||
}
|
||||
PrepareEmailTask* prepare = (PrepareEmailTask*)&(*parent);
|
||||
mMailMessage->setSender(ServerConfig::g_EmailAccount.sender);
|
||||
|
||||
if (prepare->send(mMailMessage)) {
|
||||
er->sendErrorsAsEmail();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (mEmail) {
|
||||
auto em = EmailManager::getInstance();
|
||||
em->addEmail(mEmail);
|
||||
mEmail = nullptr;
|
||||
}
|
||||
//printf("[SendEmailTask] time: %s\n", timeUsed.string().data());
|
||||
return 0;
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
#ifndef GRADIDO_LOGIN_SERVER_TASKS_SEND_EMAIL_TASK_INCLUDE
|
||||
#define GRADIDO_LOGIN_SERVER_TASKS_SEND_EMAIL_TASK_INCLUDE
|
||||
|
||||
#include "CPUTask.h"
|
||||
#include "Poco/Net/MailMessage.h"
|
||||
|
||||
#include "../model/email/Email.h"
|
||||
|
||||
/*
|
||||
* @author: Dario Rekowski
|
||||
*
|
||||
* @date: 29.09.19
|
||||
* @desc: Task for send an email, the first parent dependence pointer must be a prepare email task
|
||||
*/
|
||||
|
||||
|
||||
class SendEmailTask : public UniLib::controller::CPUTask
|
||||
{
|
||||
public:
|
||||
|
||||
SendEmailTask(Poco::Net::MailMessage* mailMessage, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount = 0);
|
||||
SendEmailTask(model::Email* email, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount = 0);
|
||||
virtual ~SendEmailTask();
|
||||
|
||||
virtual int run();
|
||||
|
||||
virtual const char* getResourceType() const { return "SendEmailTask"; };
|
||||
protected:
|
||||
|
||||
private:
|
||||
Poco::Net::MailMessage* mMailMessage;
|
||||
model::Email* mEmail;
|
||||
};
|
||||
|
||||
|
||||
#endif //GRADIDO_LOGIN_SERVER_TASKS_SEND_EMAIL_TASK_INCLUDE
|
||||
@ -12,15 +12,6 @@ server {
|
||||
|
||||
root /var/www/cakephp/webroot;
|
||||
index index.php;
|
||||
|
||||
location ~* \.(png|jpg|ico|webp)$ {
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
location ~* \.(js|css) {
|
||||
# expires 1d;
|
||||
expires 1d;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass community-server:9000;
|
||||
@ -67,9 +58,33 @@ server {
|
||||
proxy_pass http://login-server:1201;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /vue {
|
||||
|
||||
|
||||
location /vue/sockjs-node {
|
||||
rewrite /vue/(.*) /$1;
|
||||
}
|
||||
location ~* \.(png) {
|
||||
expires 1d;
|
||||
rewrite /vue/(.*) /$1;
|
||||
}
|
||||
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Host $host;
|
||||
#rewrite /vue/(.*) /$1 break;
|
||||
|
||||
proxy_pass http://frontend:8080;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
# access_log /var/log/nginx/access.log main;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gradido",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "Gradido",
|
||||
"main": "index.js",
|
||||
"repository": "git@github.com:gradido/gradido.git",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user