mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
try to fix crash while create keys, new since user is autoPtr
This commit is contained in:
parent
9177398f48
commit
ea9c34035d
2
dependencies/iroha-ed25519
vendored
2
dependencies/iroha-ed25519
vendored
@ -1 +1 @@
|
||||
Subproject commit 7307ffb8a89d2459f0c07ea5cab27c0d3496df00
|
||||
Subproject commit a0977c22d23f7e8cb596f1d9d812de74115f407b
|
||||
@ -27,6 +27,7 @@ ObfusArray::~ObfusArray()
|
||||
if (m_Data) {
|
||||
|
||||
free(m_Data);
|
||||
m_Data = nullptr;
|
||||
}
|
||||
printf("[ObfusArray::~ObfusArray] finish\n");
|
||||
}
|
||||
@ -49,17 +49,19 @@ void DashboardPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::N
|
||||
responseStream << "<div class=\"grd_container\">\n";
|
||||
responseStream << "\t<h1>Willkommen ";
|
||||
#line 28 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
printf("[DashboardPage] call get User get Name: \n");
|
||||
responseStream << ( mSession->getUser()->getName() );
|
||||
responseStream << "</h1>\n";
|
||||
responseStream << "\t";
|
||||
#line 29 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
responseStream << ( mSession->getErrorsHtml() );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t<h3>Status</h3>\n";
|
||||
responseStream << "\t<p>";
|
||||
#line 30 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
printf("[DashboardPage] call getSessionStateString: \n");
|
||||
#line 31 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
responseStream << ( mSession->getSessionStateString() );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t";
|
||||
#line 31 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
#line 32 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
if(mSession->getSessionState() == SESSION_STATE_EMAIL_VERIFICATION_SEND) { responseStream << "\n";
|
||||
responseStream << "\t<p>Verification Code E-Mail wurde erfolgreich an dich verschickt, bitte schaue auch in dein Spam-Verzeichnis nach wenn du sie nicht findest und klicke auf den Link den du dort findest oder kopiere den Code hier her:</p>\n";
|
||||
responseStream << "\t<form method=\"GET\" action=\"checkEmail\">\n";
|
||||
@ -67,9 +69,10 @@ printf("[DashboardPage] call getSessionStateString: \n");
|
||||
responseStream << "\t\t<input class=\"grd_bn_succeed\" type=\"submit\" value=\"Überprüfe Code\">\n";
|
||||
responseStream << "\t</form>\n";
|
||||
responseStream << "\t";
|
||||
#line 37 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
#line 38 "/home/rock/code/gradido_login_server/src/cpsp/dashboard.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t<a class=\"grd_bn\" href=\"logout\">Abmelden</a>\n";
|
||||
responseStream << "\t<a class=\"grd_bn\" href=\"user_delete\">Account löschen</a>\n";
|
||||
responseStream << "</div>\n";
|
||||
responseStream << "</body>\n";
|
||||
responseStream << "</html>\n";
|
||||
|
||||
@ -65,6 +65,13 @@ Poco::Net::HTTPRequestHandler* PageRequestHandlerFactory::createRequestHandler(c
|
||||
printf("session released\n");
|
||||
return new LoginPage;
|
||||
}
|
||||
if(url_first_part == "/user_delete") {
|
||||
if(s->deleteUser()) {
|
||||
sm->releseSession(s);
|
||||
return new LoginPage;
|
||||
}
|
||||
|
||||
}
|
||||
auto sessionState = s->getSessionState();
|
||||
if(sessionState == SESSION_STATE_EMAIL_VERIFICATION_CODE_CHECKED ||
|
||||
sessionState == SESSION_STATE_PASSPHRASE_GENERATED) {
|
||||
|
||||
@ -71,7 +71,7 @@ void PassphrasePage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::
|
||||
responseStream << "<head>\n";
|
||||
responseStream << "<meta charset=\"UTF-8\">\n";
|
||||
responseStream << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n";
|
||||
responseStream << "<title>Gradido Login Server: Merkspruch</title>\n";
|
||||
responseStream << "<title>Gradido Login Server: Passphrase</title>\n";
|
||||
responseStream << "<!--<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styles.min.css\">-->\n";
|
||||
responseStream << "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://gradido2.dario-rekowski.de/css/styles.css\">\n";
|
||||
responseStream << "<style type=\"text/css\" >\n";
|
||||
@ -109,7 +109,7 @@ void PassphrasePage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::
|
||||
if(state == PAGE_SHOW_PASSPHRASE) { responseStream << "\n";
|
||||
responseStream << "\t\t<div class=\"grd_text-max-width\">\n";
|
||||
responseStream << "\t\t\t<div class=\"grd_text\">\n";
|
||||
responseStream << "\t\t\t\tSchreibe dir den Merkspruch auf und packe ihn gut weg. Du brauchst ihn um deine Adresse wiederherzustellen. Wenn du ihn verlierst, sind auch deine Gradidos verloren.\n";
|
||||
responseStream << "\t\t\t\tSchreibe dir die Passphrase auf und packe sie gut weg. Du brauchst sie um deine Adresse wiederherzustellen. Wenn du ihn verlierst, sind auch deine Gradidos verloren.\n";
|
||||
responseStream << "\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t<div class=\"grd_textarea\">\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
|
||||
@ -268,8 +268,6 @@ void SessionManager::checkTimeoutSession()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CheckSessionTimeouted::run()
|
||||
{
|
||||
SessionManager::getInstance()->checkTimeoutSession();
|
||||
|
||||
@ -298,7 +298,7 @@ bool Session::isPwdValid(const std::string& pwd)
|
||||
bool Session::loadUser(const std::string& email, const std::string& password)
|
||||
{
|
||||
Profiler usedTime;
|
||||
if (mSessionUser) delete mSessionUser;
|
||||
if (mSessionUser) mSessionUser = nullptr;
|
||||
mSessionUser = new User(email.data());
|
||||
if (!mSessionUser->validatePwd(password)) {
|
||||
addError(new Error("Login", "E-Mail oder Passwort nicht korrekt, bitte versuche es erneut"));
|
||||
@ -309,6 +309,19 @@ bool Session::loadUser(const std::string& email, const std::string& password)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Session::deleteUser()
|
||||
{
|
||||
bool bResult = false;
|
||||
if(mSessionUser) {
|
||||
bResult = mSessionUser->deleteFromDB();
|
||||
}
|
||||
if(!bResult) {
|
||||
addError(new Error("Benutzer", "Fehler beim löschen des Accounts. Bitte logge dich erneut ein und versuche es nochmal."));
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/*
|
||||
SESSION_STATE_CRYPTO_KEY_GENERATED,
|
||||
SESSION_STATE_USER_WRITTEN,
|
||||
|
||||
@ -55,6 +55,8 @@ public:
|
||||
bool createUser(const std::string& name, const std::string& email, const std::string& password);
|
||||
// TODO: check if email exist and if not, fake waiting on password hashing with profiled times of real password hashing
|
||||
bool loadUser(const std::string& email, const std::string& password);
|
||||
|
||||
bool deleteUser();
|
||||
|
||||
bool loadFromEmailVerificationCode(Poco::UInt64 emailVerificationCode);
|
||||
|
||||
|
||||
@ -272,6 +272,33 @@ bool User::validatePwd(const std::string& pwd)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool User::deleteFromDB()
|
||||
{
|
||||
auto cm = ConnectionManager::getInstance();
|
||||
auto em = ErrorManager::getInstance();
|
||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
|
||||
Poco::Data::Statement deleteFromDB(session);
|
||||
//DELETE FROM `table_name` [WHERE condition];
|
||||
|
||||
deleteFromDB
|
||||
<< "DELETE from users where id = ?;"
|
||||
<< "DELETE from email_opt_in where user_id = ?;"
|
||||
<< "DELETE from user_backups where user_id = ?",
|
||||
use(mDBId), use(mDBId), use(mDBId);
|
||||
|
||||
try {
|
||||
auto result = deleteFromDB.execute();
|
||||
printf("[User::deleteFromDB] deleted: %d\n", result);
|
||||
} catch(Poco::Exception& ex) {
|
||||
em->addError(new ParamError("[User::deleteFromDB]", "error deleting user tables", ex.displayText().data()));
|
||||
em->sendErrorsAsEmail();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void User::duplicate()
|
||||
{
|
||||
mReferenceCount++;
|
||||
|
||||
@ -38,6 +38,8 @@ public:
|
||||
|
||||
bool loadEntryDBId(Poco::Data::Session session);
|
||||
|
||||
bool deleteFromDB();
|
||||
|
||||
inline bool hasCryptoKey() { lock(); bool bRet = mCryptoKey != nullptr; unlock(); return bRet; }
|
||||
|
||||
inline const char* getEmail() const { return mEmail.data(); }
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
<body>
|
||||
<div class="grd_container">
|
||||
<h1>Willkommen <%= mSession->getUser()->getName() %></h1>
|
||||
<%= mSession->getErrorsHtml() %>
|
||||
<h3>Status</h3>
|
||||
<p><%= mSession->getSessionStateString() %></p>
|
||||
<% if(mSession->getSessionState() == SESSION_STATE_EMAIL_VERIFICATION_SEND) { %>
|
||||
@ -36,6 +37,7 @@
|
||||
</form>
|
||||
<% } %>
|
||||
<a class="grd_bn" href="logout">Abmelden</a>
|
||||
<a class="grd_bn" href="user_delete">Account löschen</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -50,7 +50,7 @@ enum PageState
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Gradido Login Server: Merkspruch</title>
|
||||
<title>Gradido Login Server: Passphrase</title>
|
||||
<!--<link rel="stylesheet" type="text/css" href="css/styles.min.css">-->
|
||||
<link rel="stylesheet" type="text/css" href="https://gradido2.dario-rekowski.de/css/styles.css">
|
||||
<style type="text/css" >
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user