mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Core/Accounts: prevent existing account ban from being updated
Signed-off-by: jackpoz <giacomopoz@gmail.com>
This commit is contained in:
2
sql/updates/world/3.3.5/2017_12_16_04_world.sql
Normal file
2
sql/updates/world/3.3.5/2017_12_16_04_world.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
DELETE FROM `trinity_string` WHERE `entry`=1188;
|
||||||
|
INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES (1188, 'Ban exists');
|
||||||
@@ -390,6 +390,18 @@ std::string AccountMgr::CalculateShaPassHash(std::string const& name, std::strin
|
|||||||
return ByteArrayToHexStr(sha.GetDigest(), sha.GetLength());
|
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)
|
bool AccountMgr::IsPlayerAccount(uint32 gmlevel)
|
||||||
{
|
{
|
||||||
return gmlevel == SEC_PLAYER;
|
return gmlevel == SEC_PLAYER;
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class TC_GAME_API AccountMgr
|
|||||||
static uint32 GetCharactersCount(uint32 accountId);
|
static uint32 GetCharactersCount(uint32 accountId);
|
||||||
|
|
||||||
static std::string CalculateShaPassHash(std::string const& name, std::string const& password);
|
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 IsPlayerAccount(uint32 gmlevel);
|
||||||
static bool IsAdminAccount(uint32 gmlevel);
|
static bool IsAdminAccount(uint32 gmlevel);
|
||||||
static bool IsConsoleAccount(uint32 gmlevel);
|
static bool IsConsoleAccount(uint32 gmlevel);
|
||||||
|
|||||||
@@ -999,7 +999,8 @@ enum TrinityStrings
|
|||||||
LANG_GROUP_NOT_IN_RAID_GROUP = 1185,
|
LANG_GROUP_NOT_IN_RAID_GROUP = 1185,
|
||||||
LANG_GROUP_ROLE_CHANGED = 1186,
|
LANG_GROUP_ROLE_CHANGED = 1186,
|
||||||
LANG_LEADER_CANNOT_BE_ASSISTANT = 1187,
|
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
|
// Debug commands
|
||||||
LANG_DO_NOT_USE_6X_DEBUG_AREATRIGGER_LEFT = 1999,
|
LANG_DO_NOT_USE_6X_DEBUG_AREATRIGGER_LEFT = 1999,
|
||||||
|
|||||||
@@ -3367,7 +3367,8 @@ enum BanReturn
|
|||||||
{
|
{
|
||||||
BAN_SUCCESS,
|
BAN_SUCCESS,
|
||||||
BAN_SYNTAX_ERROR,
|
BAN_SYNTAX_ERROR,
|
||||||
BAN_NOTFOUND
|
BAN_NOTFOUND,
|
||||||
|
BAN_EXISTS
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BattlegroundTeamId
|
enum BattlegroundTeamId
|
||||||
|
|||||||
@@ -2671,6 +2671,10 @@ BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, uint32 du
|
|||||||
PreparedQueryResult resultAccounts = PreparedQueryResult(nullptr); //used for kicking
|
PreparedQueryResult resultAccounts = PreparedQueryResult(nullptr); //used for kicking
|
||||||
PreparedStatement* stmt = nullptr;
|
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
|
///- Update the database with ban information
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -233,6 +233,9 @@ public:
|
|||||||
}
|
}
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
|
case BAN_EXISTS:
|
||||||
|
handler->PSendSysMessage(LANG_BAN_EXISTS);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user