Core/Accounts: prevent existing account ban from being updated

Signed-off-by: jackpoz <giacomopoz@gmail.com>
This commit is contained in:
Gogs
2017-12-17 19:11:06 +01:00
committed by jackpoz
parent 657683df7e
commit fbb2b1650f
7 changed files with 26 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
DELETE FROM `trinity_string` WHERE `entry`=1188;
INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES (1188, 'Ban exists');

View File

@@ -390,6 +390,18 @@ std::string AccountMgr::CalculateShaPassHash(std::string const& name, std::strin
return ByteArrayToHexStr(sha.GetDigest(), sha.GetLength());
}
bool AccountMgr::IsBannedAccount(std::string const& name)
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME);
stmt->setString(0, name);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
return false;
return true;
}
bool AccountMgr::IsPlayerAccount(uint32 gmlevel)
{
return gmlevel == SEC_PLAYER;

View File

@@ -75,6 +75,7 @@ class TC_GAME_API AccountMgr
static uint32 GetCharactersCount(uint32 accountId);
static std::string CalculateShaPassHash(std::string const& name, std::string const& password);
static bool IsBannedAccount(std::string const& name);
static bool IsPlayerAccount(uint32 gmlevel);
static bool IsAdminAccount(uint32 gmlevel);
static bool IsConsoleAccount(uint32 gmlevel);

View File

@@ -999,7 +999,8 @@ enum TrinityStrings
LANG_GROUP_NOT_IN_RAID_GROUP = 1185,
LANG_GROUP_ROLE_CHANGED = 1186,
LANG_LEADER_CANNOT_BE_ASSISTANT = 1187,
// Room for more level 3 1188-1198 not used
LANG_BAN_EXISTS = 1188,
// Room for more level 3 1189-1198 not used
// Debug commands
LANG_DO_NOT_USE_6X_DEBUG_AREATRIGGER_LEFT = 1999,

View File

@@ -3367,7 +3367,8 @@ enum BanReturn
{
BAN_SUCCESS,
BAN_SYNTAX_ERROR,
BAN_NOTFOUND
BAN_NOTFOUND,
BAN_EXISTS
};
enum BattlegroundTeamId

View File

@@ -2671,6 +2671,10 @@ BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, uint32 du
PreparedQueryResult resultAccounts = PreparedQueryResult(nullptr); //used for kicking
PreparedStatement* stmt = nullptr;
// Prevent banning an already banned account
if (mode == BAN_ACCOUNT && AccountMgr::IsBannedAccount(nameOrIP))
return BAN_EXISTS;
///- Update the database with ban information
switch (mode)
{

View File

@@ -233,6 +233,9 @@ public:
}
handler->SetSentErrorMessage(true);
return false;
case BAN_EXISTS:
handler->PSendSysMessage(LANG_BAN_EXISTS);
break;
}
return true;