mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
send UpdateGroupMember Transaction via hedera in separate task after last sign
This commit is contained in:
parent
e2b9884ddb
commit
ead0ec9edf
@ -153,7 +153,7 @@ MemoryBin* KeyPairEd25519::sign(const unsigned char* message, size_t messageSize
|
||||
|
||||
bool KeyPairEd25519::verify(const std::string& message, const std::string& signature) const
|
||||
{
|
||||
if (message != "" || signature != "") return false;
|
||||
if (message == "" || signature == "") return false;
|
||||
if (crypto_sign_verify_detached((const unsigned char*)signature.data(), (const unsigned char*)message.data(), message.size(), mSodiumPublic) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -71,8 +71,7 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
{
|
||||
transaction = dynamic_cast<model::gradido::Transaction*>(transactions_to_sign[0].get());
|
||||
transaction_body = transaction->getTransactionBody();
|
||||
}
|
||||
|
||||
|
||||
if(!form.empty()) {
|
||||
auto ok = form.get("ok", "");
|
||||
auto abort = form.get("abort", "");
|
||||
@ -147,50 +146,61 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(abort != "")
|
||||
if(abort != "")
|
||||
{
|
||||
//mSession->finalizeTransaction(false, true);
|
||||
//
|
||||
if(transaction && transaction->getModel()->getUserId() == user_model->getID())
|
||||
// make sure we have the correct transaction
|
||||
transaction = nullptr;
|
||||
transaction_body.assign(nullptr);
|
||||
for(auto it = transactions_to_sign.begin(); it != transactions_to_sign.end(); it++)
|
||||
{
|
||||
transaction->deleteFromDB();
|
||||
printf("deleted from db\n");
|
||||
transaction_body.assign(nullptr);
|
||||
printf("assign nullptr to transaction_body\n");
|
||||
transactions_to_sign.clear();
|
||||
printf("clear list \n");
|
||||
transaction = nullptr;
|
||||
|
||||
}
|
||||
}
|
||||
else if(ok != "")
|
||||
{
|
||||
if(!account_user->hasPassword()) {
|
||||
auto pwd = form.get("sign-password", "");
|
||||
auto loginResult = account_user->login(pwd);
|
||||
switch(loginResult) {
|
||||
case 0:
|
||||
addError(new Error(gettext("Passwort"), gettext("Das Passwort stimmt nicht. Bitte verwende dein Passwort von der Registrierung")));
|
||||
hasErrors = true;
|
||||
break;
|
||||
case -1:
|
||||
case -2:
|
||||
addError(new Error(gettext("Passwort"), gettext("Gespeicherte Daten sind korrupt!")));
|
||||
hasErrors = true;
|
||||
state = PAGE_USER_DATA_CORRUPTED;
|
||||
break;
|
||||
case -3:
|
||||
addError(new Error(gettext("Passwort"), gettext("Passwortprüfung läuft schon, bitte versuche es in 1-2 Minuten erneut.")));
|
||||
hasErrors = true;
|
||||
if((*it)->getModel()->getID() == pending_task_id) {
|
||||
transaction = dynamic_cast<model::gradido::Transaction*>(it->get());
|
||||
transaction_body = transaction->getTransactionBody();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!hasErrors) {
|
||||
mSession->finalizeTransaction(true, false);
|
||||
if(abort != "")
|
||||
{
|
||||
//mSession->finalizeTransaction(false, true);
|
||||
//
|
||||
if(transaction && transaction->getModel()->getUserId() == user_model->getID())
|
||||
{
|
||||
transaction->deleteFromDB();
|
||||
transaction_body.assign(nullptr);
|
||||
transactions_to_sign.clear();
|
||||
transaction = nullptr;
|
||||
}
|
||||
}
|
||||
else if(ok != "")
|
||||
{
|
||||
if(!account_user->hasPassword()) {
|
||||
auto pwd = form.get("sign-password", "");
|
||||
auto loginResult = account_user->login(pwd);
|
||||
switch(loginResult) {
|
||||
case 0:
|
||||
addError(new Error(gettext("Passwort"), gettext("Das Passwort stimmt nicht. Bitte verwende dein Passwort von der Registrierung")));
|
||||
hasErrors = true;
|
||||
break;
|
||||
case -1:
|
||||
case -2:
|
||||
addError(new Error(gettext("Passwort"), gettext("Gespeicherte Daten sind korrupt!")));
|
||||
hasErrors = true;
|
||||
state = PAGE_USER_DATA_CORRUPTED;
|
||||
break;
|
||||
case -3:
|
||||
addError(new Error(gettext("Passwort"), gettext("Passwortprüfung läuft schon, bitte versuche es in 1-2 Minuten erneut.")));
|
||||
hasErrors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!hasErrors) {
|
||||
//mSession->finalizeTransaction(true, false);
|
||||
transaction->sign(account_user);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addError(new Error(gettext("Form Error"), gettext("error with field")));
|
||||
}
|
||||
} else {
|
||||
addError(new Error(gettext("Form Error"), gettext("error with field")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,120 +452,120 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "<div class=\"content-container main-container\">\n";
|
||||
responseStream << "\t<div class=\"action-form\">\n";
|
||||
responseStream << "\t\t<p class=\"form-header\">";
|
||||
#line 178 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 174 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktion Unterzeichnen") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t<div class=\"form-content\">\n";
|
||||
responseStream << "\t\t";
|
||||
#line 180 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 176 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(state == PAGE_TRANSACTION_TRANSFER) {
|
||||
auto transferTransaction = transaction_body->getTransferTransaction();
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t<p>";
|
||||
#line 183 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 179 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Überweisung") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t\t<div class=\"content-table\">\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row content-row-header\">\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 186 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 182 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Konto") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 187 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 183 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Gradido") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 189 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 185 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
for(int i = 0; i < transferTransaction->getKontoTableSize(); i++) { responseStream << "\t\t\t\t\t\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 190 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 186 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if((i+1) % 2 == 0) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<div class=\"content-row content-row\">\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 192 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 188 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<div class=\"content-row content-row-bg\">\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 194 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 190 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t";
|
||||
#line 195 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 191 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( transferTransaction->getKontoNameCell(i) );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t";
|
||||
#line 196 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 192 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( transferTransaction->getAmountCell(i) );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 198 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 194 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 200 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 196 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else if(PAGE_TRANSACTION_CREATION == state) {
|
||||
auto creationTransaction = transaction_body->getCreationTransaction();
|
||||
auto transactionUser = creationTransaction->getUser();
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<p>";
|
||||
#line 204 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 200 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Schöpfung") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t\t\t<div class=\"content-table\">\n";
|
||||
responseStream << "\t\t\t\t <div class=\"content-row content-row-header\">\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 207 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 203 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Konto") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 208 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 204 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Zieldatum") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 209 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 205 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Gradido") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t\t <div class=\"content-row content-row-bg\">\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 212 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 208 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(!transactionUser.isNull()) {
|
||||
auto user_model = transactionUser->getModel();
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 215 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 211 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getFirstName() );
|
||||
responseStream << " ";
|
||||
#line 215 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 211 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getLastName() );
|
||||
responseStream << " <";
|
||||
#line 215 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 211 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getEmail() );
|
||||
responseStream << "></span>\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 216 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 212 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<span class=\"content-cell\">0x";
|
||||
#line 217 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 213 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( creationTransaction->getPublicHex() );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 218 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 214 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 219 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 215 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( creationTransaction->getTargetDateString() );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell success-color\">";
|
||||
#line 220 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 216 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( creationTransaction->getAmountString() );
|
||||
responseStream << " GDD</span>\n";
|
||||
responseStream << "\t\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t\t</div>\n";
|
||||
responseStream << "\t\t ";
|
||||
#line 223 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 219 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else if(PAGE_TRANSACTION_GROUP_ADD_MEMBER == state) {
|
||||
auto groupMemberUpdateTransaction = transaction_body->getGroupMemberUpdate();
|
||||
auto groups = controller::Group::load(groupMemberUpdateTransaction->getTargetGroupAlias());
|
||||
@ -570,99 +580,99 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
}
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t <p>";
|
||||
#line 236 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 232 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Benutzer zu einer Gruppe hinzufügen") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t\t <div class=\"content-table\">\n";
|
||||
responseStream << "\t\t\t\t<p>";
|
||||
#line 238 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 234 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(!user.isNull()) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<b>Benutzer:</b> ";
|
||||
#line 239 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 235 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user->getEmailWithNames() );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 240 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 236 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<b>Account public key:</b> ";
|
||||
#line 241 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 237 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( groupMemberUpdateTransaction->getPublicKeyHex() );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 242 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 238 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "</p>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 243 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 239 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(!group_model.isNull()) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<p><b>";
|
||||
#line 244 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 240 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Gruppe") );
|
||||
responseStream << ":</b></p>\n";
|
||||
responseStream << "\t\t\t\t\t<ul>\n";
|
||||
responseStream << "\t\t\t\t\t\t<li>";
|
||||
#line 246 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 242 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Name") );
|
||||
responseStream << ": ";
|
||||
#line 246 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 242 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( group_model->getName() );
|
||||
responseStream << "</li>\n";
|
||||
responseStream << "\t\t\t\t\t\t<li>";
|
||||
#line 247 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 243 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Alias") );
|
||||
responseStream << ": ";
|
||||
#line 247 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 243 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( group_model->getAlias() );
|
||||
responseStream << "</li>\n";
|
||||
responseStream << "\t\t\t\t\t\t<li>";
|
||||
#line 248 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 244 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Url") );
|
||||
responseStream << ": <a href=\"";
|
||||
#line 248 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 244 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( group_model->getUrl() );
|
||||
responseStream << "/pages/visitor\" target=\"_blank\">";
|
||||
#line 248 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 244 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( group_model->getUrl() );
|
||||
responseStream << "</a></li>\n";
|
||||
responseStream << "\t\t\t\t\t\t<li>";
|
||||
#line 249 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 245 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( group_model->getDescription() );
|
||||
responseStream << "</li>\n";
|
||||
responseStream << "\t\t\t\t\t</ul>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 251 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 247 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 252 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 248 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Unbekannte Gruppe") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 253 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 249 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 254 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 250 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Es haben bereits ") );
|
||||
#line 254 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 250 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( std::to_string(transaction->getSignCount()) );
|
||||
#line 254 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 250 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext(" unterzeichnet") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t \n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 257 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 253 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else if(PAGE_USER_DATA_CORRUPTED == state) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<p class=\"alert-color\">";
|
||||
#line 258 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 254 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Es gibt ein Problem mit deinen gespeicherten Daten, bitte wende dich an den"));
|
||||
responseStream << "<a href=\"mailto:";
|
||||
#line 258 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 254 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( em->getAdminReceiver());
|
||||
responseStream << "?subject=Corrupt User Data&body=Hallo Dario,%0D%0A%0D%0Ameine Benutzer Daten sind korrupt.%0D%0Akannst du das prüfen?%0D%0A%0D%0AMit freundlichen Grüßen%0D%0A\">";
|
||||
#line 258 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 254 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << (gettext("Support") );
|
||||
responseStream << "</a></p>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 259 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 255 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t<div class=\"content-table\">\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row content-row-header\">\n";
|
||||
@ -670,7 +680,7 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row\">\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 265 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 261 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getNameWithEmailHtml() );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
@ -681,49 +691,49 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row content-row-bg\">\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 273 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 269 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( memo );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t<form>\n";
|
||||
responseStream << "\t\t\t\t<input type=\"hidden\" name=\"pending-task-id\" value=\"";
|
||||
#line 277 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 273 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( transaction->getModel()->getID() );
|
||||
responseStream << "\">\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 278 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 274 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(!account_user->hasPassword()) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t <div class=\"form-group\">\n";
|
||||
responseStream << "\t\t\t\t\t <label for=\"sign-password\">";
|
||||
#line 280 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 276 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Ich brauche nochmal dein Passwort") );
|
||||
responseStream << "</label>\n";
|
||||
responseStream << "\t\t\t\t\t <input type=\"password\" class=\"form-control\" id=\"sign-password\" name=\"sign-password\" placeholder=\"";
|
||||
#line 281 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 277 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Passwort") );
|
||||
responseStream << "\">\n";
|
||||
responseStream << "\t\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 283 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 279 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 284 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 280 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(PAGE_USER_DATA_CORRUPTED != state && user_model->isEmailChecked()) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<button type=\"submit\" class=\"form-button\" name=\"ok\" value=\"ok\">\n";
|
||||
responseStream << "\t\t\t\t\t\t<i class=\"material-icons-outlined\">verified_user</i>\n";
|
||||
responseStream << "\t\t\t\t\t\t";
|
||||
#line 287 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 283 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktion unterzeichnen") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t</button>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 289 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 285 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<button type=\"submit\" class=\"form-button button-cancel\" name=\"abort\" value=\"abort\">\n";
|
||||
responseStream << "\t\t\t\t\t<i class=\"material-icons-outlined\">delete</i>\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 292 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 288 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktion verwerfen") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t</button>\n";
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#include "PendingTasksManager.h"
|
||||
#include "../lib/JsonRequest.h"
|
||||
#include "ErrorManager.h"
|
||||
|
||||
|
||||
PendingTasksManager::PendingTasksManager()
|
||||
{
|
||||
@ -143,3 +146,29 @@ std::vector<Poco::AutoPtr<controller::PendingTask>> PendingTasksManager::getTra
|
||||
}
|
||||
return transactions_to_sign;
|
||||
}
|
||||
|
||||
void PendingTasksManager::reportErrorToCommunityServer(Poco::AutoPtr<controller::PendingTask> task, std::string error, std::string errorDetails)
|
||||
{
|
||||
// TODO: choose user specific server
|
||||
JsonRequest phpServerRequest(ServerConfig::g_php_serverHost, ServerConfig::g_phpServerPort);
|
||||
//Poco::Net::NameValueCollection payload;
|
||||
Poco::JSON::Object payload;
|
||||
|
||||
auto task_model = task->getModel();
|
||||
auto user_model = task->getUser()->getModel();
|
||||
|
||||
payload.set("created", task_model->getCreated());
|
||||
payload.set("id", task_model->getID());
|
||||
payload.set("public_key", user_model->getPublicKeyHex());
|
||||
payload.set("error", error);
|
||||
payload.set("errorMessage", errorDetails);
|
||||
|
||||
auto ret = phpServerRequest.request("errorInTransaction", payload);
|
||||
if (ret == JSON_REQUEST_RETURN_ERROR)
|
||||
{
|
||||
auto em = ErrorManager::getInstance();
|
||||
em->addError(new Error("PendingTasksManager::reportErrorToCommunityServer", "php server error"));
|
||||
em->getErrors(&phpServerRequest);
|
||||
em->sendErrorsAsEmail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,8 +42,12 @@ public:
|
||||
std::vector<Poco::AutoPtr<controller::PendingTask>> getPendingTasks(Poco::AutoPtr<controller::User> user, model::table::TaskType type);
|
||||
std::vector<Poco::AutoPtr<controller::PendingTask>> getTransactionsUserMustSign(Poco::AutoPtr<controller::User> user);
|
||||
|
||||
void reportErrorToCommunityServer(Poco::AutoPtr<controller::PendingTask> task, std::string error, std::string errorDetails);
|
||||
|
||||
protected:
|
||||
PendingTasksManager();
|
||||
|
||||
|
||||
|
||||
|
||||
std::map<int, PendingTaskList*> mPendingTasks;
|
||||
|
||||
@ -84,4 +84,19 @@ namespace controller {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Poco::AutoPtr<controller::User> PendingTask::getUser()
|
||||
{
|
||||
if (!mUser.isNull()) {
|
||||
return mUser;
|
||||
}
|
||||
auto user_id = getModel()->getUserId();
|
||||
if (!user_id) {
|
||||
return nullptr;
|
||||
}
|
||||
mUser = controller::User::create();
|
||||
mUser->load(user_id);
|
||||
return mUser;
|
||||
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
#include "Poco/SharedPtr.h"
|
||||
|
||||
#include "TableControllerBase.h"
|
||||
#include "User.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
@ -35,10 +36,14 @@ namespace controller {
|
||||
//! \return -1 error, more runs needed
|
||||
//! \return -2 critical error, abort, remove
|
||||
virtual int run() { return false; };
|
||||
|
||||
Poco::AutoPtr<controller::User> getUser();
|
||||
|
||||
protected:
|
||||
static Poco::AutoPtr<PendingTask> loadCorrectDerivedClass(model::table::PendingTask* dbModel);
|
||||
PendingTask(model::table::PendingTask* dbModel);
|
||||
|
||||
Poco::AutoPtr<controller::User> mUser;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -2,12 +2,16 @@
|
||||
#include "JsonRequest.h"
|
||||
#include "Profiler.h"
|
||||
|
||||
#include "Poco/JSON/Object.h"
|
||||
|
||||
#include "Poco/Net/HTTPSClientSession.h"
|
||||
#include "Poco/Net/HTTPRequest.h"
|
||||
#include "Poco/Net/HTTPResponse.h"
|
||||
#include "Poco/JSON/Parser.h"
|
||||
|
||||
#include "sodium.h"
|
||||
#include "../SingletonManager/MemoryManager.h"
|
||||
#include "DataTypeConverter.h"
|
||||
|
||||
JsonRequest::JsonRequest(const std::string& serverHost, int serverPort)
|
||||
: mServerHost(serverHost), mServerPort(serverPort)
|
||||
{
|
||||
@ -19,16 +23,10 @@ JsonRequest::~JsonRequest()
|
||||
|
||||
}
|
||||
|
||||
|
||||
JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::Net::NameValueCollection& payload)
|
||||
JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::JSON::Object& requestJson)
|
||||
{
|
||||
static const char* functionName = "JsonRequest::request";
|
||||
Poco::JSON::Object requestJson;
|
||||
requestJson.set("method", methodName);
|
||||
|
||||
for(auto it = payload.begin(); it != payload.end(); it++) {
|
||||
requestJson.set(it->first, it->second);
|
||||
}
|
||||
//requestJson.set("user", std::string(mSessionUser->getPublicKeyHex()));
|
||||
|
||||
// send post request via https
|
||||
@ -102,6 +100,19 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::Net::
|
||||
|
||||
return JSON_REQUEST_RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::Net::NameValueCollection& payload)
|
||||
{
|
||||
Poco::JSON::Object requestJson;
|
||||
requestJson.set("method", methodName);
|
||||
|
||||
for (auto it = payload.begin(); it != payload.end(); it++) {
|
||||
requestJson.set(it->first, it->second);
|
||||
}
|
||||
return request(methodName, requestJson);
|
||||
}
|
||||
#include "Poco/JSON/Stringifier.h"
|
||||
JsonRequestReturn JsonRequest::requestGRPCRelay(const Poco::Net::NameValueCollection& payload)
|
||||
{
|
||||
@ -192,3 +203,4 @@ JsonRequestReturn JsonRequest::requestGRPCRelay(const Poco::Net::NameValueCollec
|
||||
|
||||
return JSON_REQUEST_RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "NotificationList.h"
|
||||
#include "Poco/Net/NameValueCollection.h"
|
||||
#include "Poco/JSON/Object.h"
|
||||
|
||||
#ifndef __GRADIDO_LOGIN_SERVER_LIB_JSON_REQUEST_
|
||||
#define __GRADIDO_LOGIN_SERVER_LIB_JSON_REQUEST_
|
||||
@ -29,6 +30,7 @@ public:
|
||||
~JsonRequest();
|
||||
|
||||
JsonRequestReturn request(const char* methodName, const Poco::Net::NameValueCollection& payload);
|
||||
JsonRequestReturn request(const char* methodName, const Poco::JSON::Object& payload);
|
||||
JsonRequestReturn requestGRPCRelay(const Poco::Net::NameValueCollection& payload);
|
||||
|
||||
protected:
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
#include "Transaction.h"
|
||||
#include "../../SingletonManager/ErrorManager.h"
|
||||
#include "../../SingletonManager/PendingTasksManager.h"
|
||||
#include "../../SingletonManager/LanguageManager.h"
|
||||
#include "../../ServerConfig.h"
|
||||
|
||||
#include "../../controller/HederaId.h"
|
||||
#include "../../controller/HederaAccount.h"
|
||||
#include "../../controller/HederaRequest.h"
|
||||
|
||||
#include "../hedera/Transaction.h"
|
||||
|
||||
#include "../../tasks/HederaTask.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
namespace model {
|
||||
namespace gradido {
|
||||
@ -75,7 +88,7 @@ namespace model {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Transaction::addSign(Poco::AutoPtr<controller::User> user)
|
||||
bool Transaction::sign(Poco::AutoPtr<controller::User> user)
|
||||
{
|
||||
static const char function_name[] = "Transaction::addSign";
|
||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||
@ -169,6 +182,12 @@ namespace model {
|
||||
mm->releaseMemory(sign);
|
||||
|
||||
updateRequestInDB();
|
||||
// check if enough signatures exist for next step
|
||||
if (getSignCount() >= mTransactionBody->getTransactionBase()->getMinSignatureCount())
|
||||
{
|
||||
UniLib::controller::TaskPtr transaction_send_task(new SendTransactionTask(Poco::AutoPtr<Transaction>(this, true)));
|
||||
transaction_send_task->scheduleTask(transaction_send_task);
|
||||
}
|
||||
|
||||
//getModel()->updateIntoDB("request", )
|
||||
|
||||
@ -183,7 +202,7 @@ namespace model {
|
||||
mProtoTransaction.SerializeToString(&transaction_serialized);
|
||||
auto model = getModel();
|
||||
model->setRequest(transaction_serialized);
|
||||
return 1 == model->updateIntoDB("request", model->getRequest());
|
||||
return model->updateRequest();
|
||||
}
|
||||
|
||||
TransactionValidation Transaction::validate()
|
||||
@ -193,7 +212,8 @@ 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())) {
|
||||
return TRANSACTION_VALID_INVALID_SIGN;
|
||||
@ -203,8 +223,7 @@ namespace model {
|
||||
auto transaction_base = mTransactionBody->getTransactionBase();
|
||||
auto result = transaction_base->checkRequiredSignatures(&sig_map);
|
||||
|
||||
if (result == TRANSACTION_VALID_OK)
|
||||
{
|
||||
if (result == TRANSACTION_VALID_OK) {
|
||||
return transaction_base->validate();
|
||||
}
|
||||
return result;
|
||||
@ -251,7 +270,140 @@ namespace model {
|
||||
auto transaction_base = mTransactionBody->getTransactionBase();
|
||||
return !transaction_base->isPublicKeyForbidden(user->getModel()->getPublicKey());
|
||||
}
|
||||
|
||||
int Transaction::runSendTransaction()
|
||||
{
|
||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||
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
|
||||
|| TRANSACTION_VALID_INVALID_SIGN == result) {
|
||||
addError(new ParamError(function_name, "code error", TransactionValidationToString(result)));
|
||||
sendErrorsAsEmail();
|
||||
|
||||
} else if (mTransactionBody->isGroupMemberUpdate()) {
|
||||
addError(new ParamError(function_name, "validation return: ", TransactionValidationToString(result)));
|
||||
sendErrorsAsEmail();
|
||||
}
|
||||
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:
|
||||
error_name = t->gettext_str("Signature Error");
|
||||
error_description = t->gettext_str("Invalid signature!");
|
||||
break;
|
||||
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;
|
||||
case TRANSACTION_VALID_CREATION_OUT_OF_BORDER:
|
||||
error_name = t->gettext_str("Creation Error");
|
||||
error_description = t->gettext_str("Maximal 1000 GDD per month allowed!");
|
||||
break;
|
||||
case TRANSACTION_VALID_INVALID_AMOUNT:
|
||||
error_name = t->gettext_str("Transfer Error");
|
||||
error_description = t->gettext_str("Invalid GDD amount! Amount must be greater than 0 and maximal your balance.");
|
||||
break;
|
||||
case TRANSACTION_VALID_INVALID_GROUP_ALIAS:
|
||||
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:
|
||||
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)));
|
||||
sendErrorsAsEmail();
|
||||
}
|
||||
|
||||
auto pt = PendingTasksManager::getInstance();
|
||||
pt->reportErrorToCommunityServer(Poco::AutoPtr<Transaction>(this, true), error_name, error_description);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// send transaction via hedera
|
||||
auto network_type = table::HEDERA_TESTNET;
|
||||
// TODO: get correct topic id for user group
|
||||
int user_group_id = 1;
|
||||
auto topic_id = controller::HederaId::find(user_group_id, network_type);
|
||||
auto hedera_operator_account = controller::HederaAccount::pick(network_type, false);
|
||||
|
||||
if (!topic_id.isNull() && !hedera_operator_account.isNull())
|
||||
{
|
||||
auto crypto_key = hedera_operator_account->getCryptoKey();
|
||||
if (!crypto_key.isNull())
|
||||
{
|
||||
model::hedera::ConsensusSubmitMessage consensus_submit_message(topic_id);
|
||||
consensus_submit_message.setMessage(mProtoTransaction.SerializeAsString());
|
||||
auto hedera_transaction_body = hedera_operator_account->createTransactionBody();
|
||||
hedera_transaction_body->setConsensusSubmitMessage(consensus_submit_message);
|
||||
model::hedera::Transaction hedera_transaction;
|
||||
hedera_transaction.sign(crypto_key->getKeyPair(), std::move(hedera_transaction_body));
|
||||
|
||||
HederaRequest hedera_request;
|
||||
HederaTask hedera_task;// placeholder
|
||||
if (HEDERA_REQUEST_RETURN_OK != hedera_request.request(&hedera_transaction, &hedera_task))
|
||||
{
|
||||
addError(new Error(function_name, "error send transaction to hedera"));
|
||||
getErrors(&hedera_request);
|
||||
sendErrorsAsEmail();
|
||||
return -2;
|
||||
}
|
||||
else {
|
||||
auto hedera_precheck_code_string = hedera_task.getTransactionResponse()->getPrecheckCodeString();
|
||||
auto cost = hedera_task.getTransactionResponse()->getCost();
|
||||
|
||||
printf("hedera response: %s, cost: %" PRIu64 "\n", hedera_precheck_code_string.data(), cost);
|
||||
|
||||
}
|
||||
//model::hedera::TransactionBody hedera_transaction_body()
|
||||
}
|
||||
else
|
||||
{
|
||||
addError(new ParamError(function_name, "hedera crypto key not found for paying for consensus submit message! NetworkType: ", network_type));
|
||||
sendErrorsAsEmail();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addError(new Error(function_name, "hedera topic id or operator account not found!"));
|
||||
addError(new ParamError(function_name, "user group id: ", user_group_id));
|
||||
addError(new ParamError(function_name, "network type: ", network_type));
|
||||
sendErrorsAsEmail();
|
||||
return -4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// TASK ////////////////////////
|
||||
SendTransactionTask::SendTransactionTask(Poco::AutoPtr<Transaction> transaction)
|
||||
: UniLib::controller::CPUTask(ServerConfig::g_CPUScheduler), mTransaction(transaction)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int SendTransactionTask::run()
|
||||
{
|
||||
auto result = mTransaction->runSendTransaction();
|
||||
|
||||
if (-1 == result) {
|
||||
mTransaction->deleteFromDB();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,7 @@
|
||||
#include "../../tasks/GradidoTask.h"
|
||||
#include "../../controller/User.h"
|
||||
|
||||
#include "../tasks/CPUTask.h"
|
||||
|
||||
namespace model {
|
||||
namespace gradido {
|
||||
@ -28,9 +29,12 @@ namespace model {
|
||||
static Poco::AutoPtr<Transaction> create(Poco::AutoPtr<controller::User> user, Poco::AutoPtr<controller::Group> group);
|
||||
static Poco::AutoPtr<Transaction> load(model::table::PendingTask* dbModel);
|
||||
|
||||
bool addSign(Poco::AutoPtr<controller::User> user);
|
||||
bool sign(Poco::AutoPtr<controller::User> user);
|
||||
int getSignCount() { return mProtoTransaction.sig_map().sigpair_size(); }
|
||||
TransactionValidation validate();
|
||||
|
||||
//! \brief validate and if valid send transaction via Hedera Consensus Service to node server
|
||||
int runSendTransaction();
|
||||
|
||||
inline Poco::AutoPtr<TransactionBody> getTransactionBody() { Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex); return mTransactionBody; }
|
||||
|
||||
@ -51,6 +55,18 @@ namespace model {
|
||||
proto::gradido::GradidoTransaction mProtoTransaction;
|
||||
HASH mBodyBytesHash;
|
||||
};
|
||||
|
||||
class SendTransactionTask : public UniLib::controller::CPUTask
|
||||
{
|
||||
public:
|
||||
SendTransactionTask(Poco::AutoPtr<Transaction> transaction);
|
||||
|
||||
const char* getResourceType() const { return "SendTransactionTask"; };
|
||||
int run();
|
||||
protected:
|
||||
Poco::AutoPtr<Transaction> mTransaction;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,27 @@
|
||||
namespace model {
|
||||
namespace gradido {
|
||||
|
||||
|
||||
const char* TransactionValidationToString(TransactionValidation result)
|
||||
{
|
||||
switch (result) {
|
||||
case TRANSACTION_VALID_OK: return "ok";
|
||||
case TRANSACTION_VALID_MISSING_SIGN: return "missing sign";
|
||||
case TRANSACTION_VALID_FORBIDDEN_SIGN: return "forbidden sign";
|
||||
case TRANSACTION_VALID_MISSING_PARAM: return "missing param";
|
||||
case TRANSACTION_VALID_CODE_ERROR: return "code error";
|
||||
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_GROUP_ALIAS: return "invalid group alias";
|
||||
case TRANSACTION_VALID_INVALID_SIGN: return "invalid sign";
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
TransactionBase::TransactionBase(const std::string& memo)
|
||||
: mMemo(memo), mMinSignatureCount(0), mIsPrepared(false)
|
||||
{
|
||||
|
||||
@ -31,6 +31,7 @@ namespace model {
|
||||
TRANSACTION_VALID_INVALID_GROUP_ALIAS,
|
||||
TRANSACTION_VALID_INVALID_SIGN
|
||||
};
|
||||
const char* TransactionValidationToString(TransactionValidation result);
|
||||
|
||||
class TransactionBase : public NotificationList, public UniLib::lib::MultithreadContainer
|
||||
{
|
||||
@ -44,13 +45,15 @@ namespace model {
|
||||
static std::string amountToString(google::protobuf::int64 amount);
|
||||
inline const std::string& getMemo() const { return mMemo; }
|
||||
|
||||
//! \return true if all required signatures are found in signature pairs
|
||||
//! \return TRANSACTION_VALID_OK if all required signatures are found in signature pairs
|
||||
TransactionValidation checkRequiredSignatures(const proto::gradido::SignatureMap* sig_map);
|
||||
//! \param pubkey pointer must point to valid unsigned char[KeyPairEd25519::getPublicKeySize()] array
|
||||
bool isPublicKeyRequired(const unsigned char* pubkey);
|
||||
//! \param pubkey pointer must point to valid unsigned char[KeyPairEd25519::getPublicKeySize()] array
|
||||
bool isPublicKeyForbidden(const unsigned char* pubkey);
|
||||
|
||||
inline Poco::UInt32 getMinSignatureCount() { return mMinSignatureCount; }
|
||||
|
||||
protected:
|
||||
std::string mMemo;
|
||||
Poco::UInt32 mMinSignatureCount;
|
||||
|
||||
@ -36,6 +36,31 @@ namespace model
|
||||
mRequest.assignRaw((const unsigned char*)serializedProto.data(), serializedProto.size());
|
||||
}
|
||||
|
||||
bool PendingTask::updateRequest()
|
||||
{
|
||||
Poco::ScopedLock<Poco::Mutex> _poco_lock(mWorkMutex);
|
||||
SHARED_LOCK;
|
||||
if (!mID) {
|
||||
return 0;
|
||||
}
|
||||
auto cm = ConnectionManager::getInstance();
|
||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
|
||||
Poco::Data::Statement update(session);
|
||||
|
||||
update << "UPDATE " << getTableName() << " SET request = ? where id = ?;",
|
||||
use(mRequest), use(mID);
|
||||
|
||||
try {
|
||||
return 1 == update.execute();
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
addError(new ParamError(getTableName(), "[updateRequest] mysql error by update", ex.displayText().data()));
|
||||
addError(new ParamError(getTableName(), "data set: \n", toString().data()));
|
||||
}
|
||||
//printf("data valid: %s\n", toString().data());
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string PendingTask::toString()
|
||||
{
|
||||
|
||||
@ -37,10 +37,14 @@ namespace model {
|
||||
const char* getTableName() const { return "pending_tasks"; }
|
||||
std::string toString();
|
||||
|
||||
//! \brief update table row with current request
|
||||
bool updateRequest();
|
||||
|
||||
inline int getUserId() const { SHARED_LOCK; return mUserId; }
|
||||
inline TaskType getTaskType() const { SHARED_LOCK; return (TaskType)mTaskTypeId; }
|
||||
inline const std::vector<unsigned char>& getRequest() const { SHARED_LOCK; return mRequest.content(); }
|
||||
inline std::string getRequestCopy() const { SHARED_LOCK; return std::string((const char*)mRequest.content().data(), mRequest.content().size()); }
|
||||
inline Poco::DateTime getCreated() const { SHARED_LOCK; return mCreated; }
|
||||
inline TaskType getTaskType() const { SHARED_LOCK; return (TaskType)mTaskTypeId; }
|
||||
|
||||
inline void setUserId(int userId) { UNIQUE_LOCK; mUserId = userId; }
|
||||
inline void setTaskType(TaskType type) { UNIQUE_LOCK; mTaskTypeId = type; }
|
||||
|
||||
@ -53,8 +53,7 @@ enum PageState {
|
||||
{
|
||||
transaction = dynamic_cast<model::gradido::Transaction*>(transactions_to_sign[0].get());
|
||||
transaction_body = transaction->getTransactionBody();
|
||||
}
|
||||
|
||||
|
||||
if(!form.empty()) {
|
||||
auto ok = form.get("ok", "");
|
||||
auto abort = form.get("abort", "");
|
||||
@ -129,50 +128,61 @@ enum PageState {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(abort != "")
|
||||
if(abort != "")
|
||||
{
|
||||
//mSession->finalizeTransaction(false, true);
|
||||
//
|
||||
if(transaction && transaction->getModel()->getUserId() == user_model->getID())
|
||||
// make sure we have the correct transaction
|
||||
transaction = nullptr;
|
||||
transaction_body.assign(nullptr);
|
||||
for(auto it = transactions_to_sign.begin(); it != transactions_to_sign.end(); it++)
|
||||
{
|
||||
transaction->deleteFromDB();
|
||||
printf("deleted from db\n");
|
||||
transaction_body.assign(nullptr);
|
||||
printf("assign nullptr to transaction_body\n");
|
||||
transactions_to_sign.clear();
|
||||
printf("clear list \n");
|
||||
transaction = nullptr;
|
||||
|
||||
}
|
||||
}
|
||||
else if(ok != "")
|
||||
{
|
||||
if(!account_user->hasPassword()) {
|
||||
auto pwd = form.get("sign-password", "");
|
||||
auto loginResult = account_user->login(pwd);
|
||||
switch(loginResult) {
|
||||
case 0:
|
||||
addError(new Error(gettext("Passwort"), gettext("Das Passwort stimmt nicht. Bitte verwende dein Passwort von der Registrierung")));
|
||||
hasErrors = true;
|
||||
break;
|
||||
case -1:
|
||||
case -2:
|
||||
addError(new Error(gettext("Passwort"), gettext("Gespeicherte Daten sind korrupt!")));
|
||||
hasErrors = true;
|
||||
state = PAGE_USER_DATA_CORRUPTED;
|
||||
break;
|
||||
case -3:
|
||||
addError(new Error(gettext("Passwort"), gettext("Passwortprüfung läuft schon, bitte versuche es in 1-2 Minuten erneut.")));
|
||||
hasErrors = true;
|
||||
if((*it)->getModel()->getID() == pending_task_id) {
|
||||
transaction = dynamic_cast<model::gradido::Transaction*>(it->get());
|
||||
transaction_body = transaction->getTransactionBody();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!hasErrors) {
|
||||
mSession->finalizeTransaction(true, false);
|
||||
if(abort != "")
|
||||
{
|
||||
//mSession->finalizeTransaction(false, true);
|
||||
//
|
||||
if(transaction && transaction->getModel()->getUserId() == user_model->getID())
|
||||
{
|
||||
transaction->deleteFromDB();
|
||||
transaction_body.assign(nullptr);
|
||||
transactions_to_sign.clear();
|
||||
transaction = nullptr;
|
||||
}
|
||||
}
|
||||
else if(ok != "")
|
||||
{
|
||||
if(!account_user->hasPassword()) {
|
||||
auto pwd = form.get("sign-password", "");
|
||||
auto loginResult = account_user->login(pwd);
|
||||
switch(loginResult) {
|
||||
case 0:
|
||||
addError(new Error(gettext("Passwort"), gettext("Das Passwort stimmt nicht. Bitte verwende dein Passwort von der Registrierung")));
|
||||
hasErrors = true;
|
||||
break;
|
||||
case -1:
|
||||
case -2:
|
||||
addError(new Error(gettext("Passwort"), gettext("Gespeicherte Daten sind korrupt!")));
|
||||
hasErrors = true;
|
||||
state = PAGE_USER_DATA_CORRUPTED;
|
||||
break;
|
||||
case -3:
|
||||
addError(new Error(gettext("Passwort"), gettext("Passwortprüfung läuft schon, bitte versuche es in 1-2 Minuten erneut.")));
|
||||
hasErrors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!hasErrors) {
|
||||
//mSession->finalizeTransaction(true, false);
|
||||
transaction->sign(account_user);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addError(new Error(gettext("Form Error"), gettext("error with field")));
|
||||
}
|
||||
} else {
|
||||
addError(new Error(gettext("Form Error"), gettext("error with field")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user