aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorForesterDev <11771800+ForesterDev@users.noreply.github.com>2020-06-20 23:49:18 +0400
committerShauren <shauren.trinity@gmail.com>2020-06-22 11:03:31 +0200
commit01d098830a64622262226f7915f872e1cfb301f6 (patch)
treee661241759f8202646cc0add8f7517dab4a06193 /src/server/scripts/Commands
parentfce9fca9002e5bfc99990b9108aa56447e5001bd (diff)
DB/Account: update account_access table (#24788)
* DB/Account: update account_access table: - rename fields id -> AccountID, gmlevel -> SecurityLevel - add Comment field - rename command .acc set gmlevel to .acc set seclevel * Update auth database * Fix primary key * Temporary restore old command account set gmlevel with same handler as account set seclevel Use Optional for realmID - if not set, use -1 (for all realms) * Rename 2020_XX_XX_00_auth.sql to 2020_06_20_00_auth.sql * Update auth_database.sql * Rename 2020_XX_XX_00_world.sql to 2020_06_20_06_world.sql Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> (cherry picked from commit 8e0365d8a6ca5628ad17e6684743d9ab2138c068)
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_account.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index b12c72921dd..1d3d8b4fad5 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -50,7 +50,8 @@ public:
{
{ "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "" },
{ "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, NULL, "", accountSetSecTable },
- { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleAccountSetGmLevelCommand, "" },
+ { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SECLEVEL, true, &HandleAccountSetSecLevelCommand, "" }, // temp for a transition period
+ { "seclevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SECLEVEL, true, &HandleAccountSetSecLevelCommand, "" },
{ "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_PASSWORD, true, &HandleAccountSetPasswordCommand, "" },
};
static std::vector<ChatCommand> accountLockCommandTable =
@@ -536,8 +537,8 @@ public:
static bool HandleAccountCommand(ChatHandler* handler, char const* /*args*/)
{
// GM Level
- AccountTypes gmLevel = handler->GetSession()->GetSecurity();
- handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, int32(gmLevel));
+ AccountTypes securityLevel = handler->GetSession()->GetSecurity();
+ handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(securityLevel));
// Security level required
bool hasRBAC = (handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE) ? true : false);
@@ -636,7 +637,7 @@ public:
return true;
}
- static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, char const* args)
+ static bool HandleAccountSetSecLevelCommand(ChatHandler* handler, char const* args)
{
if (!*args)
{
@@ -645,10 +646,9 @@ public:
return false;
}
- std::string targetAccountName;
- uint32 targetAccountId = 0;
- uint32 targetSecurity = 0;
- uint32 gm = 0;
+ std::string accountName;
+ uint32 accountId = 0;
+ uint8 securityLevel = 0;
char* arg1 = strtok((char*)args, " ");
char* arg2 = strtok(NULL, " ");
char* arg3 = strtok(NULL, " ");
@@ -668,18 +668,18 @@ public:
// Check for account
if (isAccountNameGiven)
{
- targetAccountName = arg1;
- if (!Utf8ToUpperOnlyLatin(targetAccountName) || !AccountMgr::GetId(targetAccountName))
+ accountName = arg1;
+ if (!Utf8ToUpperOnlyLatin(accountName) || !AccountMgr::GetId(accountName))
{
- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, targetAccountName.c_str());
+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true);
return false;
}
}
// Check for invalid specified GM level.
- gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
- if (gm > SEC_CONSOLE)
+ securityLevel = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
+ if (securityLevel > SEC_CONSOLE)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
@@ -687,18 +687,18 @@ public:
}
// handler->getSession() == NULL only for console
- targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
- int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
+ accountId = (isAccountNameGiven) ? AccountMgr::GetId(accountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
+ int32 realmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
uint32 playerSecurity;
if (handler->GetSession())
- playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
+ playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), realmID);
else
playerSecurity = SEC_CONSOLE;
// can set security level only for target with less security and to less security that we have
// This also restricts setting handler's own security.
- targetSecurity = AccountMgr::GetSecurity(targetAccountId, gmRealmID);
- if (targetSecurity >= playerSecurity || gm >= playerSecurity)
+ uint32 targetSecurity = AccountMgr::GetSecurity(accountId, realmID);
+ if (targetSecurity >= playerSecurity || securityLevel >= playerSecurity)
{
handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
handler->SetSentErrorMessage(true);
@@ -706,12 +706,12 @@ public:
}
// Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
- if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
+ if (realmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
{
- LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST);
+ LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_SECLEVEL_TEST);
- stmt->setUInt32(0, targetAccountId);
- stmt->setUInt8(1, uint8(gm));
+ stmt->setUInt32(0, accountId);
+ stmt->setUInt8(1, securityLevel);
PreparedQueryResult result = LoginDatabase.Query(stmt);
@@ -724,7 +724,7 @@ public:
}
// Check if provided realmID has a negative value other than -1
- if (gmRealmID < -1)
+ if (realmID < -1)
{
handler->SendSysMessage(LANG_INVALID_REALMID);
handler->SetSentErrorMessage(true);
@@ -732,9 +732,9 @@ public:
}
rbac::RBACData* rbac = isAccountNameGiven ? NULL : handler->getSelectedPlayer()->GetSession()->GetRBACData();
- sAccountMgr->UpdateAccountAccess(rbac, targetAccountId, uint8(gm), gmRealmID);
+ sAccountMgr->UpdateAccountAccess(rbac, accountId, securityLevel, realmID);
- handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
+ handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, accountName.c_str(), securityLevel);
return true;
}