summaryrefslogtreecommitdiff
path: root/src/account-server/accounthandler.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-11-09 23:37:22 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-11-09 23:37:22 +0100
commit8369416cdfd2782860032bc524b5c58c0f1c06a7 (patch)
treefc6fe85961d594564b55b8faeeae52494d21bedd /src/account-server/accounthandler.cpp
parent2a56e837b5d0c7ac2611e1941dd1447f704145ed (diff)
downloadmanaserv-8369416cdfd2782860032bc524b5c58c0f1c06a7.tar.gz
manaserv-8369416cdfd2782860032bc524b5c58c0f1c06a7.tar.bz2
manaserv-8369416cdfd2782860032bc524b5c58c0f1c06a7.tar.xz
manaserv-8369416cdfd2782860032bc524b5c58c0f1c06a7.zip
Fixed unregistering on the server-side.
When registering or logging, The client is hashing the password for sending it safely. And the server is hashing it also to store it the same way. Hence, the password ends hashed twice, which is correct because the server can't trust the client anyway. At unregister attempt, the server wasn't hashing the password before comparing it. Also while on it, I made the corresponding SQL query use the try catch method and only delete the account in memory when it's also done on the Db. Reviewed-by: thorbjorn, Freeyorp.
Diffstat (limited to 'src/account-server/accounthandler.cpp')
-rw-r--r--src/account-server/accounthandler.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index 8fa0576c..d76a6b1b 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -535,8 +535,6 @@ void AccountHandler::handleUnregisterMessage(AccountClient &client,
MessageIn &msg)
{
LOG_DEBUG("AccountHandler::handleUnregisterMessage");
- std::string username = msg.readString();
- std::string password = msg.readString();
MessageOut reply(APMSG_UNREGISTER_RESPONSE);
@@ -547,6 +545,9 @@ void AccountHandler::handleUnregisterMessage(AccountClient &client,
return;
}
+ std::string username = msg.readString();
+ std::string password = msg.readString();
+
if (stringFilter->findDoubleQuotes(username))
{
reply.writeInt8(ERRMSG_INVALID_ARGUMENT);
@@ -557,7 +558,7 @@ void AccountHandler::handleUnregisterMessage(AccountClient &client,
// See whether the account exists
Account *acc = storage->getAccount(username);
- if (!acc || acc->getPassword() != password)
+ if (!acc || acc->getPassword() != sha256(password))
{
reply.writeInt8(ERRMSG_INVALID_ARGUMENT);
client.send(reply);