From f38c5f50ef310787cf1dfdf37dc9187d7b70792c Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Wed, 3 Aug 2011 16:51:14 +0200 Subject: [PATCH] server crash fix --- common/protocol_datastructures.h | 1 + common/server.cpp | 1 + servatrice/src/servatrice.cpp | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/protocol_datastructures.h b/common/protocol_datastructures.h index a3843a3d..83e72158 100644 --- a/common/protocol_datastructures.h +++ b/common/protocol_datastructures.h @@ -53,6 +53,7 @@ public: ServerInfo_User(const ServerInfo_User *other, bool complete = true); static SerializableItem *newItem() { return new ServerInfo_User; } QString getName() const { return static_cast(itemMap.value("name"))->getData(); } + void setName(const QString &_name) { static_cast(itemMap.value("name"))->setData(_name); } int getUserLevel() const { return static_cast(itemMap.value("userlevel"))->getData(); } void setUserLevel(int _userLevel) { static_cast(itemMap.value("userlevel"))->setData(_userLevel); } QString getRealName() const { return static_cast(itemMap.value("real_name"))->getData(); } diff --git a/common/server.cpp b/common/server.cpp index a1ee532c..c09a38d6 100644 --- a/common/server.cpp +++ b/common/server.cpp @@ -73,6 +73,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString while (users.contains(tempName) || userExists(tempName)) tempName = name + "_" + QString::number(++i); name = tempName; + data->setName(name); } session->setUserInfo(data); diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index 5fc24619..6933e83b 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -220,7 +220,7 @@ bool Servatrice::userExists(const QString &user) checkSql(); QSqlQuery query; - query.prepare("select 1 from " + dbPrefix + "_users where name = :name"); + query.prepare("select 1 from " + dbPrefix + "_users where name = :name and active = 1"); query.bindValue(":name", user); if (!execSqlQuery(query)) return false; @@ -423,4 +423,4 @@ void Servatrice::shutdownTimeout() deleteLater(); } -const QString Servatrice::versionString = "Servatrice 0.20110625"; +const QString Servatrice::versionString = "Servatrice 0.20110803";