mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add option for auto-sign in json request to able to use both versions
This commit is contained in:
parent
55922753a7
commit
483d3dc444
@ -31,6 +31,7 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int balance = 0;
|
int balance = 0;
|
||||||
|
|
||||||
if (!paramJsonObject->isNull("balance")) {
|
if (!paramJsonObject->isNull("balance")) {
|
||||||
paramJsonObject->get("balance").convert(balance);
|
paramJsonObject->get("balance").convert(balance);
|
||||||
if (balance) {
|
if (balance) {
|
||||||
@ -47,11 +48,16 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
|||||||
|
|
||||||
std::string transactionBase64String;
|
std::string transactionBase64String;
|
||||||
Poco::Dynamic::Var transaction_base64 = paramJsonObject->get("transaction_base64");
|
Poco::Dynamic::Var transaction_base64 = paramJsonObject->get("transaction_base64");
|
||||||
|
bool auto_sign = false;
|
||||||
|
auto auto_sign_json = paramJsonObject->get("auto_sign");
|
||||||
|
if (!auto_sign_json.isEmpty()) {
|
||||||
|
auto_sign_json.convert(auto_sign);
|
||||||
|
}
|
||||||
|
|
||||||
if (transaction_base64.isString()) {
|
if (transaction_base64.isString()) {
|
||||||
paramJsonObject->get("transaction_base64").convert(transactionBase64String);
|
paramJsonObject->get("transaction_base64").convert(transactionBase64String);
|
||||||
|
|
||||||
if (!session->startProcessingTransaction(transactionBase64String)) {
|
if (!session->startProcessingTransaction(transactionBase64String, auto_sign)) {
|
||||||
auto lastError = session->getLastError();
|
auto lastError = session->getLastError();
|
||||||
if (lastError) delete lastError;
|
if (lastError) delete lastError;
|
||||||
result->set("state", "error");
|
result->set("state", "error");
|
||||||
@ -65,7 +71,7 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
|||||||
|
|
||||||
for (int i = 0; i < ds["transaction_base64"].size(); i++) {
|
for (int i = 0; i < ds["transaction_base64"].size(); i++) {
|
||||||
ds["transaction_base64"][i].convert(transactionBase64String);
|
ds["transaction_base64"][i].convert(transactionBase64String);
|
||||||
if (!session->startProcessingTransaction(transactionBase64String)) {
|
if (!session->startProcessingTransaction(transactionBase64String, auto_sign)) {
|
||||||
auto lastError = session->getLastError();
|
auto lastError = session->getLastError();
|
||||||
if (lastError) delete lastError;
|
if (lastError) delete lastError;
|
||||||
alreadyEnlisted++;
|
alreadyEnlisted++;
|
||||||
@ -148,7 +154,7 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
|||||||
}
|
}
|
||||||
else if (params.isDeque()) {
|
else if (params.isDeque()) {
|
||||||
result->set("state", "error");
|
result->set("state", "error");
|
||||||
result->set("meg", "deque not implemented yet");
|
result->set("msg", "deque not implemented yet");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -160,10 +166,3 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonTransaction::startProcessingTransaction(Session* session, const std::string& transactionBase64)
|
|
||||||
{
|
|
||||||
if ((ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) == ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return session->startProcessingTransaction(transactionBase64);
|
|
||||||
}
|
|
||||||
@ -659,7 +659,7 @@ int Session::comparePassphraseWithSavedKeys(const std::string& inputPassphrase,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Session::startProcessingTransaction(const std::string& proto_message_base64)
|
bool Session::startProcessingTransaction(const std::string& proto_message_base64, bool autoSign/* = false*/)
|
||||||
{
|
{
|
||||||
static const char* funcName = "Session::startProcessingTransaction";
|
static const char* funcName = "Session::startProcessingTransaction";
|
||||||
lock(funcName);
|
lock(funcName);
|
||||||
@ -687,7 +687,7 @@ bool Session::startProcessingTransaction(const std::string& proto_message_base64
|
|||||||
DRMakeStringHash(mSessionUser->getEmail()),
|
DRMakeStringHash(mSessionUser->getEmail()),
|
||||||
mSessionUser->getLanguage())
|
mSessionUser->getLanguage())
|
||||||
);
|
);
|
||||||
if ((ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) == ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) {
|
if (autoSign && (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) == ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) {
|
||||||
if (processorTask->run() != 0) {
|
if (processorTask->run() != 0) {
|
||||||
getErrors(processorTask);
|
getErrors(processorTask);
|
||||||
unlock();
|
unlock();
|
||||||
|
|||||||
@ -177,7 +177,7 @@ public:
|
|||||||
// ------------------------ transactions functions ----------------------------
|
// ------------------------ transactions functions ----------------------------
|
||||||
|
|
||||||
//! \return true if succeed
|
//! \return true if succeed
|
||||||
bool startProcessingTransaction(const std::string& proto_message_base64);
|
bool startProcessingTransaction(const std::string& proto_message_base64, bool autoSign = false);
|
||||||
//! \param working if set will filled with transaction running
|
//! \param working if set will filled with transaction running
|
||||||
Poco::AutoPtr<ProcessingTransaction> getNextReadyTransaction(size_t* working = nullptr);
|
Poco::AutoPtr<ProcessingTransaction> getNextReadyTransaction(size_t* working = nullptr);
|
||||||
bool finalizeTransaction(bool sign, bool reject);
|
bool finalizeTransaction(bool sign, bool reject);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user