diff options
-rw-r--r-- | src/account-server/storage.cpp | 48 | ||||
-rw-r--r-- | src/account-server/storage.hpp | 2 |
2 files changed, 0 insertions, 50 deletions
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp index c104b4f..cdf466d 100644 --- a/src/account-server/storage.cpp +++ b/src/account-server/storage.cpp @@ -34,7 +34,6 @@ #include "utils/functors.h" #include "utils/logger.h" #include "utils/xml.hpp" -#include "utils/sha256.h" static const char *DEFAULT_ITEM_FILE = "items.xml"; @@ -139,13 +138,6 @@ void Storage::open() std::ostringstream sql; sql << "DELETE FROM " << ONLINE_USERS_TBL_NAME; mDb->execSql(sql.str()); - - /* Uncomment this and run the account server once to update existing - * password hashes. Making backup of the database is recommended, since - * it doesn't check whether the passwords are already hashed, and the - * operation is not reversible! - */ - //updatePasswordHashes(); } catch (const DbConnectionFailure& e) { std::ostringstream errmsg; @@ -164,46 +156,6 @@ void Storage::close() } /** - * Temporary function to hash all account passwords, for updating a database - * of accounts to the change to hashing passwords on both the server and the - * client. - */ -void Storage::updatePasswordHashes() -{ - using namespace dal; - - std::ostringstream sql2; - sql2 << "SELECT id, password FROM " << ACCOUNTS_TBL_NAME; - - const RecordSet &results = mDb->execSql(sql2.str()); - if (!results.isEmpty()) { - std::vector<std::pair <unsigned, std::string > > hashed; - - const unsigned nRows = results.rows(); - - for (unsigned row = 0; row < nRows; row++) - { - string_to< unsigned > toUint; - const int id = toUint(results(row, 0)); - const std::string password = results(row, 1); - const std::string hashedPassword = sha256(password); - - hashed.push_back(std::pair<unsigned, std::string >(id, hashedPassword)); - } - - for (unsigned i = 0; i < hashed.size(); ++i) - { - std::ostringstream setsql; - setsql << "UPDATE " << ACCOUNTS_TBL_NAME << " SET password = '" - << hashed[i].second << "' WHERE id = '" << hashed[i].first << "'"; - mDb->execSql(setsql.str()); - } - - std::cout << "Hashed the passwords of " << nRows << " accounts!" << std::endl; - } -} - -/** * Gets an account from a prepared SQL statement * * @return the account found diff --git a/src/account-server/storage.hpp b/src/account-server/storage.hpp index 204e6c9..989f1b9 100644 --- a/src/account-server/storage.hpp +++ b/src/account-server/storage.hpp @@ -49,8 +49,6 @@ class Storage void open(); void close(); - void updatePasswordHashes(); - Account *getAccount(const std::string &userName); Account *getAccount(int accountID); |