Core/Accounts: prevent existing account ban from being updated
This commit is contained in:
@@ -945,7 +945,8 @@ namespace Framework.Constants
|
||||
AccountBnetUnlinked = 1188,
|
||||
AccountBnetNotLinked = 1189,
|
||||
DisallowTicketsConfig = 1190,
|
||||
// Room For More Level 3 1191-1198 Not Used
|
||||
BanExists = 1191,
|
||||
// Room For More Level 3 1192-1198 Not Used
|
||||
|
||||
// Debug Commands
|
||||
DebugAreatriggerLeft = 1999,
|
||||
|
||||
@@ -957,7 +957,8 @@ namespace Framework.Constants
|
||||
{
|
||||
Success,
|
||||
SyntaxError,
|
||||
Notfound
|
||||
Notfound,
|
||||
Exists
|
||||
}
|
||||
|
||||
public enum WorldCfg
|
||||
|
||||
@@ -331,6 +331,15 @@ namespace Game
|
||||
return sha.ComputeHash(Encoding.UTF8.GetBytes(name + ":" + password)).ToHexString();
|
||||
}
|
||||
|
||||
public bool IsBannedAccount(string name)
|
||||
{
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_BANNED_BY_USERNAME);
|
||||
stmt.AddValue(0, name);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
|
||||
return !result.IsEmpty();
|
||||
}
|
||||
|
||||
public bool IsPlayerAccount(AccountTypes gmlevel)
|
||||
{
|
||||
return gmlevel == AccountTypes.Player;
|
||||
|
||||
@@ -85,7 +85,6 @@ namespace Game.Chat.Commands
|
||||
case BanReturn.Notfound:
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.BanNotfound, "character", name);
|
||||
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
@@ -174,8 +173,10 @@ namespace Game.Chat.Commands
|
||||
handler.SendSysMessage(CypherStrings.BanNotfound, "ip", nameOrIP);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
case BanReturn.Exists:
|
||||
handler.SendSysMessage(CypherStrings.BanExists);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1459,6 +1459,10 @@ namespace Game
|
||||
/// Ban an account or ban an IP address, duration is in seconds if positive, otherwise permban
|
||||
public BanReturn BanAccount(BanMode mode, string nameOrIP, uint duration_secs, string reason, string author)
|
||||
{
|
||||
// Prevent banning an already banned account
|
||||
if (mode == BanMode.Account && Global.AccountMgr.IsBannedAccount(nameOrIP))
|
||||
return BanReturn.Exists;
|
||||
|
||||
SQLResult resultAccounts;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
@@ -1589,17 +1593,21 @@ namespace Game
|
||||
else
|
||||
guid = pBanned.GetGUID();
|
||||
|
||||
//Use transaction in order to ensure the order of the queries
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
|
||||
// make sure there is only one active ban
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_BAN);
|
||||
stmt.AddValue(0, guid.GetCounter());
|
||||
DB.Characters.Execute(stmt);
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_BAN);
|
||||
stmt.AddValue(0, guid.GetCounter());
|
||||
stmt.AddValue(1, duration_secs);
|
||||
stmt.AddValue(2, author);
|
||||
stmt.AddValue(3, reason);
|
||||
DB.Characters.Execute(stmt);
|
||||
trans.Append(stmt);
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
|
||||
if (pBanned)
|
||||
pBanned.GetSession().KickPlayer();
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
DELETE FROM `trinity_string` WHERE `entry`=1191;
|
||||
INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES (1191, 'Ban exists');
|
||||
Reference in New Issue
Block a user