64 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(username, password);
70 if (bnetAccountId && bnetIndex)
110 ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt64());
116 s->
KickPlayer(
"AccountMgr::DeleteAccount Deleting the account");
121 }
while (result->NextRow());
141 trans->Append(loginStmt);
145 trans->Append(loginStmt);
149 trans->Append(loginStmt);
153 trans->Append(loginStmt);
157 trans->Append(loginStmt);
188 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(newUsername, newPassword);
200 std::string username;
202 if (!
GetName(accountId, username))
204 sScriptMgr->OnFailedPasswordChange(accountId);
210 sScriptMgr->OnFailedPasswordChange(accountId);
216 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(username, newPassword);
230 std::string username;
232 if (!
GetName(accountId, username))
260 std::string username;
262 if (!
GetName(accountId, username))
294 return (result) ? (*result)[0].GetUInt32() : 0;
326 name = (*result)[0].GetString();
341 email = (*result)[0].GetString();
369 std::string username;
371 if (!
GetName(accountId, username))
393 std::string oldEmail;
402 if (strcmp(oldEmail.c_str(), newEmail.c_str()) == 0)
415 return (result) ? (*result)[0].GetUInt64() : 0;
455 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading permissions");
459 TC_LOG_INFO(
"server.loading",
">> Loaded 0 account permission definitions. DB table `rbac_permissions` is empty.");
465 Field* field = result->Fetch();
470 while (result->NextRow());
472 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading linked permissions");
473 result =
LoginDatabase.Query(
"SELECT id, linkedId FROM rbac_linked_permissions ORDER BY id ASC");
476 TC_LOG_INFO(
"server.loading",
">> Loaded 0 linked permissions. DB table `rbac_linked_permissions` is empty.");
485 Field* field = result->Fetch();
487 if (permissionId != newId)
489 permissionId = newId;
494 if (linkedPermissionId == permissionId)
496 TC_LOG_ERROR(
"sql.sql",
"RBAC Permission {} has itself as linked permission. Ignored", permissionId);
502 while (result->NextRow());
504 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading default permissions");
505 result =
LoginDatabase.PQuery(
"SELECT secId, permissionId FROM rbac_default_permissions WHERE (realmId = {} OR realmId = -1) ORDER BY secId ASC",
sRealmList->GetCurrentRealmId().Realm);
508 TC_LOG_INFO(
"server.loading",
">> Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty.");
516 Field* field = result->Fetch();
518 if (secId != newId || permissions ==
nullptr)
524 permissions->insert(field[1].GetUInt32());
527 while (result->NextRow());
529 TC_LOG_INFO(
"server.loading",
">> Loaded {} permission definitions, {} linked permissions and {} default permissions in {} ms", count1, count2, count3,
GetMSTimeDiffToNow(oldMSTime));
534 if (
rbac && securityLevel !=
rbac->GetSecurityLevel())
535 rbac->SetSecurityLevel(securityLevel);
568 TC_LOG_TRACE(
"rbac",
"AccountMgr::GetRBACPermission: {}", permissionId);
569 rbac::RBACPermissionsContainer::const_iterator it =
_permissions.find(permissionId);
580 TC_LOG_ERROR(
"rbac",
"AccountMgr::HasPermission: Wrong accountId 0");
586 bool hasPermission =
rbac.HasPermission(permissionId);
588 TC_LOG_DEBUG(
"rbac",
"AccountMgr::HasPermission [AccountId: {}, PermissionId: {}, realmId: {}]: {}",
589 accountId, permissionId, realmId, hasPermission);
590 return hasPermission;
595 for (std::pair<uint32 const, rbac::RBACPermission*>& permission :
_permissions)
596 delete permission.second;
Trinity::Crypto::SRP::GruntSRP6 AccountSRP6
@ CHAR_SEL_CHARS_BY_ACCOUNT_ID
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__, message__,...)
#define TC_LOG_ERROR(filterType__, message__,...)
#define TC_LOG_INFO(filterType__, message__,...)
#define TC_LOG_TRACE(filterType__, message__,...)
@ 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_SEL_CHECK_PASSWORD_BY_NAME
@ 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)
static AccountOpResult DeleteAccount(uint32 accountId)
AccountOpResult CreateAccount(std::string username, std::string password, std::string email="", uint32 bnetAccountId=0, uint8 bnetIndex=0)
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 CheckPassword(std::string username, std::string password)
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.
uint32 GetUInt32() const noexcept
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars=true, bool deleteFinally=false)
void setBinary(uint8 index, std::vector< uint8 > &&value)
void setString(uint8 index, std::string &&value)
void setUInt32(uint8 index, uint32 value)
void setInt32(uint8 index, int32 value)
void setUInt8(uint8 index, uint8 value)
void setNull(uint8 index)
bool CheckCredentials(std::string const &username, std::string const &password) const
Player session in the World.
void LogoutPlayer(bool save)
Log the player out
void KickPlayer(std::string_view 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::array< uint8, SALT_LENGTH > Salt
std::vector< uint8 > Verifier
static constexpr size_t SALT_LENGTH
std::set< uint32 > RBACPermissionContainer