Fix server crash on banning
This commit is contained in:
parent
d5afd97ff4
commit
46f78fcead
4 changed files with 21 additions and 12 deletions
|
@ -210,7 +210,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
}
|
||||
}
|
||||
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
||||
aDetails->setEnabled(online);
|
||||
aDetails->setEnabled(true);
|
||||
aChat->setEnabled(anotherUser && online);
|
||||
aShowGames->setEnabled(anotherUser);
|
||||
aAddToBuddyList->setEnabled(anotherUser);
|
||||
|
|
|
@ -124,19 +124,19 @@ void BanDialog::okClicked()
|
|||
}
|
||||
|
||||
if (nameBanCheckBox->isChecked())
|
||||
if (nameBanEdit->text() == ""){
|
||||
if (nameBanEdit->text().simplified() == ""){
|
||||
QMessageBox::critical(this, tr("Error"), tr("You must have a value in the name ban when selecting the name ban checkbox."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ipBanCheckBox->isChecked())
|
||||
if (ipBanEdit->text() == ""){
|
||||
if (ipBanEdit->text().simplified() == ""){
|
||||
QMessageBox::critical(this, tr("Error"), tr("You must have a value in the ip ban when selecting the ip ban checkbox."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (idBanCheckBox->isChecked())
|
||||
if (idBanCheckBox->text() == ""){
|
||||
if (idBanEdit->text().simplified() == ""){
|
||||
QMessageBox::critical(this, tr("Error"), tr("You must have a value in the clientid ban when selecting the clientid ban checkbox."));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "pb/event_user_message.pb.h"
|
||||
#include "pb/event_game_joined.pb.h"
|
||||
#include "pb/event_room_say.pb.h"
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include "featureset.h"
|
||||
|
||||
|
@ -536,12 +537,14 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetUserInfo(const Command_GetU
|
|||
QReadLocker locker(&server->clientsLock);
|
||||
|
||||
ServerInfo_User_Container *infoSource = server->findUser(userName);
|
||||
if (!infoSource)
|
||||
return Response::RespNameNotFound;
|
||||
|
||||
re->mutable_user_info()->CopyFrom(infoSource->copyUserInfo(true, false, userInfo->user_level() & ServerInfo_User::IsModerator));
|
||||
if (!infoSource) {
|
||||
re->mutable_user_info()->CopyFrom(databaseInterface->getUserData(userName,true));
|
||||
} else {
|
||||
re->mutable_user_info()->CopyFrom(infoSource->copyUserInfo(true, false, userInfo->user_level() & ServerInfo_User::IsModerator));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rc.setResponseExtension(re);
|
||||
return Response::RespOk;
|
||||
}
|
||||
|
|
|
@ -768,8 +768,13 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
|||
if (!sqlInterface->checkSql())
|
||||
return Response::RespInternalError;
|
||||
|
||||
QString userName = QString::fromStdString(cmd.user_name());
|
||||
QString address = QString::fromStdString(cmd.address());
|
||||
QString userName = QString::fromStdString(cmd.user_name()).simplified();
|
||||
QString address = QString::fromStdString(cmd.address()).simplified();
|
||||
QString clientID = QString::fromStdString(cmd.clientid()).simplified();
|
||||
|
||||
if (userName.isEmpty() && address.isEmpty() && clientID.isEmpty())
|
||||
return Response::RespOk;
|
||||
|
||||
QString trustedSources = settingsCache->value("server/trusted_sources","127.0.0.1,::1").toString();
|
||||
int minutes = cmd.minutes();
|
||||
if (trustedSources.contains(address,Qt::CaseInsensitive))
|
||||
|
@ -790,10 +795,11 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
|
|||
|
||||
if (!userName.isEmpty()) {
|
||||
ServerSocketInterface *user = static_cast<ServerSocketInterface *>(server->getUsers().value(userName));
|
||||
userList.append(user);
|
||||
if (user)
|
||||
userList.append(user);
|
||||
}
|
||||
|
||||
if (userName.isEmpty() && address.isEmpty() && (!QString::fromStdString(cmd.clientid()).isEmpty())) {
|
||||
if (userName.isEmpty() && address.isEmpty() && (!clientID.isEmpty())) {
|
||||
QSqlQuery *query = sqlInterface->prepareQuery("select name from {prefix}_users where clientid = :client_id");
|
||||
query->bindValue(":client_id", QString::fromStdString(cmd.clientid()));
|
||||
sqlInterface->execSqlQuery(query);
|
||||
|
|
Loading…
Reference in a new issue