mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Core/Commands: Added new 'bnetaccount listgameaccounts' command to display all account table entries linked to a given battle.net email
* Also fixed errors about bad commands in db Closes #18474
This commit is contained in:
File diff suppressed because one or more lines are too long
7
sql/updates/auth/master/2016_12_18_00_auth.sql
Normal file
7
sql/updates/auth/master/2016_12_18_00_auth.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
DELETE FROM `rbac_permissions` WHERE `id`=830;
|
||||
INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
|
||||
(830,'Command: .bnetaccount listgameaccounts');
|
||||
|
||||
DELETE FROM `rbac_linked_permissions` WHERE `id`=196 AND `linkedId`=830;
|
||||
INSERT INTO `rbac_linked_permissions` (`id`, `linkedId`) VALUES
|
||||
(196, 830);
|
||||
12
sql/updates/world/master/2016_12_18_00_world.sql
Normal file
12
sql/updates/world/master/2016_12_18_00_world.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
DELETE FROM `command` WHERE `name`='bnetaccount listgameaccounts';
|
||||
INSERT INTO `command` (`name`,`permission`,`help`) VALUES
|
||||
('bnetaccount listgameaccounts', 830, 'Syntax: .bnetaccount listgameaccounts $email $password\nLists all game accounts linked to battle.net $email');
|
||||
|
||||
DELETE FROM `trinity_string` WHERE `entry` IN (1034,1035);
|
||||
INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
|
||||
(1034, '| Account Id | Internal name | Display name |'),
|
||||
(1035, 'Battle.net account %s has no linked game accounts.');
|
||||
|
||||
-- fix bad entries
|
||||
UPDATE `command` SET `name`='scene playpackage',`help`='Syntax: .scene playpackage #scenePackageId #playbackFlags\nPlays scene with package id and playback flags for targeted player' WHERE `name`='scene play package';
|
||||
UPDATE `command` SET `name`='reload scene_template',`help`='Syntax: .reload scene_template\nReload scene_template table.' WHERE `name`='reload scenes';
|
||||
@@ -138,6 +138,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT, "SELECT battlenet_account FROM account WHERE id = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LINK, "UPDATE account SET battlenet_account = ?, battlenet_index = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_SEL_BNET_MAX_ACCOUNT_INDEX, "SELECT MAX(battlenet_index) FROM account WHERE battlenet_account = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(LOGIN_SEL_BNET_GAME_ACCOUNT_LIST, "SELECT a.id, a.username FROM account a LEFT JOIN battlenet_accounts ba ON a.battlenet_account = ba.id WHERE ba.email = ?", CONNECTION_SYNCH);
|
||||
|
||||
PrepareStatement(LOGIN_UPD_BNET_FAILED_LOGINS, "UPDATE battlenet_accounts SET failed_logins = failed_logins + 1 WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_INS_BNET_ACCOUNT_AUTO_BANNED, "INSERT INTO battlenet_account_bans(id, bandate, unbandate, bannedby, banreason) VALUES(?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban')", CONNECTION_ASYNC);
|
||||
|
||||
@@ -129,6 +129,7 @@ enum LoginDatabaseStatements
|
||||
LOGIN_SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT,
|
||||
LOGIN_UPD_BNET_GAME_ACCOUNT_LINK,
|
||||
LOGIN_SEL_BNET_MAX_ACCOUNT_INDEX,
|
||||
LOGIN_SEL_BNET_GAME_ACCOUNT_LIST,
|
||||
|
||||
LOGIN_UPD_BNET_FAILED_LOGINS,
|
||||
LOGIN_INS_BNET_ACCOUNT_AUTO_BANNED,
|
||||
|
||||
@@ -734,7 +734,7 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMAND_TICKET_SUGGESTION_UNASSIGN = 827,
|
||||
RBAC_PERM_COMMAND_TICKET_SUGGESTION_VIEW = 828,
|
||||
RBAC_PERM_COMMAND_TICKET_RESET_ALL = 829,
|
||||
// 830 reuse
|
||||
RBAC_PERM_COMMAND_BNET_ACCOUNT_LIST_GAME_ACCOUTNS = 830,
|
||||
RBAC_PERM_COMMAND_TICKET_RESET_BUG = 831,
|
||||
RBAC_PERM_COMMAND_TICKET_RESET_COMPLAINT = 832,
|
||||
RBAC_PERM_COMMAND_TICKET_RESET_SUGGESTION = 833,
|
||||
|
||||
@@ -902,7 +902,9 @@ enum TrinityStrings
|
||||
LANG_ACCOUNT_PASS_TOO_LONG = 1031,
|
||||
LANG_ACCOUNT_CREATED_BNET_WITH_GAME = 1032,
|
||||
LANG_ACCOUNT_CREATED_BNET = 1033,
|
||||
// Room for more level 4 1034-1099 not used
|
||||
LANG_ACCOUNT_BNET_LIST_HEADER = 1034,
|
||||
LANG_ACCOUNT_BNET_LIST_NO_ACCOUNTS = 1035,
|
||||
// Room for more level 4 1036-1099 not used
|
||||
|
||||
// Level 3 (continue)
|
||||
LANG_ACCOUNT_SETADDON = 1100,
|
||||
|
||||
@@ -43,13 +43,14 @@ public:
|
||||
|
||||
static std::vector<ChatCommand> accountCommandTable =
|
||||
{
|
||||
{ "create", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "" },
|
||||
{ "gameaccountcreate", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE_GAME, true, &HandleGameAccountCreateCommand, "" },
|
||||
{ "lock", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT, false, NULL, "", accountLockCommandTable },
|
||||
{ "set", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_SET, true, NULL, "", accountSetCommandTable },
|
||||
{ "password", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "" },
|
||||
{ "link", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_LINK, true, &HandleAccountLinkCommand, "" },
|
||||
{ "unlink", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_UNLINK, true, &HandleAccountUnlinkCommand, "" },
|
||||
{ "create", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "" },
|
||||
{ "gameaccountcreate", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE_GAME, true, &HandleGameAccountCreateCommand, "" },
|
||||
{ "lock", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT, false, NULL, "", accountLockCommandTable },
|
||||
{ "set", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_SET, true, NULL, "", accountSetCommandTable },
|
||||
{ "password", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "" },
|
||||
{ "link", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_LINK, true, &HandleAccountLinkCommand, "" },
|
||||
{ "unlink", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_UNLINK, true, &HandleAccountUnlinkCommand, "" },
|
||||
{ "listgameaccounts", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_LIST_GAME_ACCOUTNS, true, &HandleListGameAccountsCommand, "" }
|
||||
};
|
||||
|
||||
static std::vector<ChatCommand> commandTable =
|
||||
@@ -460,6 +461,40 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleListGameAccountsCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* battlenetAccountName = strtok((char*)args, " ");
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_GAME_ACCOUNT_LIST);
|
||||
stmt->setString(0, battlenetAccountName);
|
||||
if (PreparedQueryResult accountList = LoginDatabase.Query(stmt))
|
||||
{
|
||||
auto formatDisplayName = [](char const* name) -> std::string
|
||||
{
|
||||
if (char const* hashPos = strchr(name, '#'))
|
||||
return std::string("WoW") + ++hashPos;
|
||||
else
|
||||
return name;
|
||||
};
|
||||
|
||||
handler->SendSysMessage("----------------------------------------------------");
|
||||
handler->SendSysMessage(LANG_ACCOUNT_BNET_LIST_HEADER);
|
||||
handler->SendSysMessage("----------------------------------------------------");
|
||||
do
|
||||
{
|
||||
Field* fields = accountList->Fetch();
|
||||
handler->PSendSysMessage("| %10u | %-16.16s | %-16.16s |", fields[0].GetUInt32(), fields[1].GetCString(), formatDisplayName(fields[1].GetCString()).c_str());
|
||||
} while (accountList->NextRow());
|
||||
handler->SendSysMessage("----------------------------------------------------");
|
||||
}
|
||||
else
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_BNET_LIST_NO_ACCOUNTS, battlenetAccountName);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_battlenet_account_commandscript()
|
||||
|
||||
Reference in New Issue
Block a user