Merge pull request #635 from gradido/login_fix_email

Change timeout for email resend to 10 Minutes
This commit is contained in:
einhornimmond 2021-07-14 13:32:24 +02:00 committed by GitHub
commit a08113eea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 81 additions and 2 deletions

View File

@ -115,7 +115,7 @@ Poco::JSON::Object* JsonSendEmail::handle(Poco::Dynamic::Var params)
return stateWarning("email already sended"); return stateWarning("email already sended");
} }
else if (2 == r) { else if (2 == r) {
return stateError("email already send less than a hour before"); return stateError("email already sent less than a 10 minutes before");
} }
} }
else if (emailType == model::EMAIL_CUSTOM_TEXT) { else if (emailType == model::EMAIL_CUSTOM_TEXT) {

View File

@ -36,6 +36,10 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::JSON:
// send post request via https // send post request via https
// 443 = HTTPS Default // 443 = HTTPS Default
// TODO: adding port into ServerConfig // TODO: adding port into ServerConfig
if (mServerHost.empty() || !mServerPort) {
addError(new Error(functionName, "server host or server port not given"));
return JSON_REQUEST_PARAMETER_ERROR;
}
try { try {
Profiler phpRequestTime; Profiler phpRequestTime;

View File

@ -20,6 +20,7 @@ enum JsonRequestReturn
JSON_REQUEST_RETURN_OK, JSON_REQUEST_RETURN_OK,
JSON_REQUEST_RETURN_PARSE_ERROR, JSON_REQUEST_RETURN_PARSE_ERROR,
JSON_REQUEST_RETURN_ERROR, JSON_REQUEST_RETURN_ERROR,
JSON_REQUEST_PARAMETER_ERROR,
JSON_REQUEST_CONNECT_ERROR JSON_REQUEST_CONNECT_ERROR
}; };

View File

@ -425,7 +425,7 @@ int Session::sendResetPasswordEmail(Poco::AutoPtr<controller::User> user, bool p
auto email_verification_model = mEmailVerificationCodeObject->getModel(); auto email_verification_model = mEmailVerificationCodeObject->getModel();
if (email_already_send) { if (email_already_send) {
auto time_elapsed = Poco::DateTime() - email_verification_model->getUpdated(); auto time_elapsed = Poco::DateTime() - email_verification_model->getUpdated();
if (time_elapsed.totalHours() < 1) { if (time_elapsed.totalMinutes() < 10) {
frequent_resend = true; frequent_resend = true;
} }
} }

View File

@ -0,0 +1,51 @@
#include "TestJsonCreateTransaction.h"
#include "JSONInterface/JsonCreateTransaction.h"
void TestJsonCreateTransaction::SetUp()
{
auto sm = SessionManager::getInstance();
//sm->init();
mUserSession = sm->getNewSession();
auto user = controller::User::create();
user->load("Jeet_bb@gmail.com");
user->login("TestP4ssword&H");
mUserSession->setUser(user);
}
void TestJsonCreateTransaction::TearDown()
{
auto sm = SessionManager::getInstance();
if (!mUserSession) {
sm->releaseSession(mUserSession);
}
}
Poco::JSON::Object::Ptr TestJsonCreateTransaction::basisSetup()
{
Poco::JSON::Object::Ptr params = new Poco::JSON::Object;
params->set("session_id", mUserSession->getHandle());
params->set("blockchain_type", "mysql");
params->set("memo", "Placolder for memo for test");
params->set("auto_sign", true);
return params;
}
TEST_F(TestJsonCreateTransaction, Creation)
{
JsonCreateTransaction jsonCall;
auto params = basisSetup();
params->set("transaction_type", "creation");
params->set("target_email", "Elfenhausen@arcor.de");
params->set("amount", 10000000);
params->set("target_date", "2021-07-13T13:00:00");
auto result = jsonCall.handle(params);
std::stringstream ss;
result->stringify(ss);
printf("result: %s\n", ss.str().data());
//*/
}

View File

@ -0,0 +1,23 @@
#ifndef __GRADIDO_LOGIN_SERVER_TEST_JSON_INTERFACE_TEST_JSON_CREATE_TRANSACTION_H
#define __GRADIDO_LOGIN_SERVER_TEST_JSON_INTERFACE_TEST_JSON_CREATE_TRANSACTION_H
#include "gtest/gtest.h"
#include "SingletonManager/SessionManager.h"
#include "Poco/JSON/Object.h"
class TestJsonCreateTransaction : public ::testing::Test
{
protected:
void SetUp() override;
void TearDown() override;
Poco::JSON::Object::Ptr basisSetup();
Session* mUserSession;
std::string mEmail;
};
#endif //__GRADIDO_LOGIN_SERVER_TEST_JSON_INTERFACE_TEST_JSON_CREATE_TRANSACTION_H