diff options
| author | ForesterDev <11771800+ForesterDev@users.noreply.github.com> | 2020-06-20 23:49:18 +0400 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-01-06 23:28:52 +0100 |
| commit | 69cadae38ae7196703ea10908860a6973dbdcddf (patch) | |
| tree | 5c789e8bcc6341320e0094ba75f6910b9c790540 /src/server/scripts/Commands | |
| parent | e38b2e8f5af078a90b33f02358e5020555a44d06 (diff) | |
DB/Account: update account_access table cherry-pick take 2 (with refactors)
(cherry picked from commit 8e0365d8a6ca5628ad17e6684743d9ab2138c068)
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_account.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index b48fd1e733b..2a3cbf577a3 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -58,7 +58,7 @@ public: static std::vector<ChatCommand> accountSetCommandTable = { { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "" }, - { "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, nullptr, "", accountSetSecTable }, + { "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, nullptr, "", accountSetSecTable }, { "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, "" }, @@ -665,7 +665,7 @@ public: return true; } - static bool HandleAccountSetSecLevelCommand(ChatHandler* handler, Optional<std::string> accountName, uint8 securityLevel, int32 realmId) + static bool HandleAccountSetSecLevelCommand(ChatHandler* handler, Optional<std::string> accountName, uint8 securityLevel, Optional<int32> realmId) { uint32 accountId; if (accountName) @@ -702,16 +702,20 @@ public: return false; } + int32 realmID = -1; + if (realmId) + realmID = *realmId; + // handler->getSession() == nullptr only for console uint32 playerSecurity; if (handler->GetSession()) - playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), realmId); + 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. - uint32 targetSecurity = AccountMgr::GetSecurity(accountId, realmId); + uint32 targetSecurity = AccountMgr::GetSecurity(accountId, realmID); if (targetSecurity >= playerSecurity || securityLevel >= playerSecurity) { handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); @@ -720,7 +724,7 @@ public: } // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1 - if (realmId == -1 && !AccountMgr::IsConsoleAccount(playerSecurity)) + if (realmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity)) { LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_SECLEVEL_TEST); @@ -738,14 +742,14 @@ public: } // Check if provided realmID has a negative value other than -1 - if (realmId < -1) + if (realmID < -1) { handler->SendSysMessage(LANG_INVALID_REALMID); handler->SetSentErrorMessage(true); return false; } - sAccountMgr->UpdateAccountAccess(nullptr, accountId, securityLevel, realmId); + sAccountMgr->UpdateAccountAccess(nullptr, accountId, securityLevel, realmID); handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, accountName->c_str(), securityLevel); return true; |
