98 ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt32());
104 s->
KickPlayer(
"AccountMgr::DeleteAccount Deleting the account");
109 }
while (result->NextRow());
133 trans->Append(loginStmt);
137 trans->Append(loginStmt);
141 trans->Append(loginStmt);
145 trans->Append(loginStmt);
149 trans->Append(loginStmt);
192 std::string username;
194 if (!
GetName(accountId, username))
196 sScriptMgr->OnFailedPasswordChange(accountId);
202 sScriptMgr->OnFailedPasswordChange(accountId);
222 std::string username;
224 if (!
GetName(accountId, username))
252 std::string username;
254 if (!
GetName(accountId, username))
286 return (result) ? (*result)[0].GetUInt32() : 0;
318 name = (*result)[0].GetString();
333 email = (*result)[0].GetString();
342 std::string username;
344 if (!
GetName(accountId, username))
366 std::string oldEmail;
375 if (strcmp(oldEmail.c_str(), newEmail.c_str()) == 0)
388 return (result) ? (*result)[0].GetUInt64() : 0;
428 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading permissions");
432 TC_LOG_INFO(
"server.loading",
">> Loaded 0 account permission definitions. DB table `rbac_permissions` is empty.");
438 Field* field = result->Fetch();
443 while (result->NextRow());
445 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading linked permissions");
446 result =
LoginDatabase.Query(
"SELECT id, linkedId FROM rbac_linked_permissions ORDER BY id ASC");
449 TC_LOG_INFO(
"server.loading",
">> Loaded 0 linked permissions. DB table `rbac_linked_permissions` is empty.");
458 Field* field = result->Fetch();
460 if (permissionId != newId)
462 permissionId = newId;
467 if (linkedPermissionId == permissionId)
469 TC_LOG_ERROR(
"sql.sql",
"RBAC Permission {} has itself as linked permission. Ignored", permissionId);
475 while (result->NextRow());
477 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading default permissions");
478 result =
LoginDatabase.PQuery(
"SELECT secId, permissionId FROM rbac_default_permissions WHERE (realmId = {} OR realmId = -1) ORDER BY secId ASC",
realm.
Id.
Realm);
481 TC_LOG_INFO(
"server.loading",
">> Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty.");
489 Field* field = result->Fetch();
491 if (secId != newId || permissions ==
nullptr)
497 permissions->insert(field[1].GetUInt32());
500 while (result->NextRow());
502 TC_LOG_INFO(
"server.loading",
">> Loaded {} permission definitions, {} linked permissions and {} default permissions in {} ms", count1, count2, count3,
GetMSTimeDiffToNow(oldMSTime));
507 if (
rbac && securityLevel !=
rbac->GetSecurityLevel())
508 rbac->SetSecurityLevel(securityLevel);
541 TC_LOG_TRACE(
"rbac",
"AccountMgr::GetRBACPermission: {}", permissionId);
542 rbac::RBACPermissionsContainer::const_iterator it =
_permissions.find(permissionId);
553 TC_LOG_ERROR(
"rbac",
"AccountMgr::HasPermission: Wrong accountId 0");
559 bool hasPermission =
rbac.HasPermission(permissionId);
561 TC_LOG_DEBUG(
"rbac",
"AccountMgr::HasPermission [AccountId: {}, PermissionId: {}, realmId: {}]: {}",
562 accountId, permissionId, realmId, hasPermission);
563 return hasPermission;
568 for (std::pair<uint32 const, rbac::RBACPermission*>& permission :
_permissions)
569 delete permission.second;
@ CHAR_SEL_CHARS_BY_ACCOUNT_ID
@ CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_TRACE(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
@ LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM
@ LOGIN_GET_ACCOUNT_ID_BY_USERNAME
@ LOGIN_SEL_ACCOUNT_BY_ID
@ LOGIN_DEL_ACCOUNT_MUTED
@ LOGIN_DEL_ACCOUNT_BANNED
@ LOGIN_DEL_ACCOUNT_ACCESS
@ LOGIN_GET_GMLEVEL_BY_REALMID
@ LOGIN_GET_USERNAME_BY_ID
@ LOGIN_INS_REALM_CHARACTERS_INIT
@ LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME
@ LOGIN_INS_ACCOUNT_ACCESS
@ LOGIN_DEL_REALM_CHARACTERS
@ LOGIN_SEL_CHECK_PASSWORD
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
size_t utf8length(std::string &utf8str)
static AccountOpResult ChangeRegEmail(uint32 accountId, std::string newEmail)
AccountOpResult CreateAccount(std::string username, std::string password, std::string email="")
static AccountOpResult DeleteAccount(uint32 accountId)
static bool CheckPassword(uint32 accountId, std::string password)
rbac::RBACPermissionsContainer _permissions
static AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail)
static uint32 GetSecurity(uint32 accountId, int32 realmId)
static AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword)
static uint32 GetCharactersCount(uint32 accountId)
void UpdateAccountAccess(rbac::RBACData *rbac, uint32 accountId, uint8 securityLevel, int32 realmId)
static bool IsPlayerAccount(uint32 gmlevel)
static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
static QueryCallback GetSecurityAsync(uint32 accountId, int32 realmId, std::function< void(uint32)> callback)
static bool IsConsoleAccount(uint32 gmlevel)
static AccountMgr * instance()
rbac::RBACPermissionContainer const & GetRBACDefaultPermissions(uint8 secLevel)
static bool HasPermission(uint32 accountId, uint32 permission, uint32 realmId)
static bool GetEmail(uint32 accountId, std::string &email)
rbac::RBACDefaultPermissionsContainer _defaultPermissions
static bool CheckEmail(uint32 accountId, std::string newEmail)
static bool IsBannedAccount(std::string const &name)
rbac::RBACPermission const * GetRBACPermission(uint32 permission) const
static bool IsAdminAccount(uint32 gmlevel)
static uint32 GetId(std::string_view username)
static bool GetName(uint32 accountId, std::string &name)
Class used to access individual fields of database query result.
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars=true, bool deleteFinally=false)
void setUInt32(uint8 index, uint32 value)
void setStringView(uint8 index, std::string_view value)
void setInt32(uint8 index, int32 value)
void setUInt8(uint8 index, uint8 value)
void setBinary(uint8 index, std::vector< uint8 > const &value)
void setString(uint8 index, std::string const &value)
static constexpr size_t SALT_LENGTH
static constexpr size_t VERIFIER_LENGTH
std::array< uint8, SALT_LENGTH > Salt
static std::pair< Salt, Verifier > MakeRegistrationData(std::string const &username, std::string const &password)
std::array< uint8, VERIFIER_LENGTH > Verifier
static bool CheckLogin(std::string const &username, std::string const &password, Salt const &salt, Verifier const &verifier)
Player session in the World.
void LogoutPlayer(bool save)
Log the player out
void KickPlayer(std::string const &reason)
Kick a player out of the World.
void AddLinkedPermission(uint32 id)
Adds a new linked Permission.
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
std::set< uint32 > RBACPermissionContainer