65 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(username, password);
71 if (bnetAccountId && bnetIndex)
111 ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt64());
117 s->
KickPlayer(
"AccountMgr::DeleteAccount Deleting the account");
122 }
while (result->NextRow());
142 trans->Append(loginStmt);
146 trans->Append(loginStmt);
150 trans->Append(loginStmt);
154 trans->Append(loginStmt);
158 trans->Append(loginStmt);
189 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(newUsername, newPassword);
201 std::string username;
203 if (!
GetName(accountId, username))
205 sScriptMgr->OnFailedPasswordChange(accountId);
211 sScriptMgr->OnFailedPasswordChange(accountId);
217 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(username, newPassword);
231 std::string username;
233 if (!
GetName(accountId, username))
261 std::string username;
263 if (!
GetName(accountId, username))
295 return (result) ? (*result)[0].GetUInt32() : 0;
327 name = (*result)[0].GetString();
342 email = (*result)[0].GetString();
370 std::string username;
372 if (!
GetName(accountId, username))
394 std::string oldEmail;
403 if (strcmp(oldEmail.c_str(), newEmail.c_str()) == 0)
416 return (result) ? (*result)[0].GetUInt64() : 0;
456 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading permissions");
460 TC_LOG_INFO(
"server.loading",
">> Loaded 0 account permission definitions. DB table `rbac_permissions` is empty.");
466 Field* field = result->Fetch();
471 while (result->NextRow());
473 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading linked permissions");
474 result =
LoginDatabase.Query(
"SELECT id, linkedId FROM rbac_linked_permissions ORDER BY id ASC");
477 TC_LOG_INFO(
"server.loading",
">> Loaded 0 linked permissions. DB table `rbac_linked_permissions` is empty.");
486 Field* field = result->Fetch();
488 if (permissionId != newId)
490 permissionId = newId;
495 if (linkedPermissionId == permissionId)
497 TC_LOG_ERROR(
"sql.sql",
"RBAC Permission {} has itself as linked permission. Ignored", permissionId);
503 while (result->NextRow());
505 TC_LOG_DEBUG(
"rbac",
"AccountMgr::LoadRBAC: Loading default permissions");
506 result =
LoginDatabase.PQuery(
"SELECT secId, permissionId FROM rbac_default_permissions WHERE (realmId = {} OR realmId = -1) ORDER BY secId ASC",
realm.
Id.
Realm);
509 TC_LOG_INFO(
"server.loading",
">> Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty.");
517 Field* field = result->Fetch();
519 if (secId != newId || permissions ==
nullptr)
525 permissions->insert(field[1].GetUInt32());
528 while (result->NextRow());
530 TC_LOG_INFO(
"server.loading",
">> Loaded {} permission definitions, {} linked permissions and {} default permissions in {} ms", count1, count2, count3,
GetMSTimeDiffToNow(oldMSTime));
535 if (
rbac && securityLevel !=
rbac->GetSecurityLevel())
536 rbac->SetSecurityLevel(securityLevel);
569 TC_LOG_TRACE(
"rbac",
"AccountMgr::GetRBACPermission: {}", permissionId);
570 rbac::RBACPermissionsContainer::const_iterator it =
_permissions.find(permissionId);
581 TC_LOG_ERROR(
"rbac",
"AccountMgr::HasPermission: Wrong accountId 0");
587 bool hasPermission =
rbac.HasPermission(permissionId);
589 TC_LOG_DEBUG(
"rbac",
"AccountMgr::HasPermission [AccountId: {}, PermissionId: {}, realmId: {}]: {}",
590 accountId, permissionId, realmId, hasPermission);
591 return hasPermission;
596 for (std::pair<uint32 const, rbac::RBACPermission*>& permission :
_permissions)
597 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__,...)
#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_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.
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars=true, bool deleteFinally=false)
void setInt32(const uint8 index, const int32 value)
void setStringView(const uint8 index, const std::string_view value)
void setUInt8(const uint8 index, const uint8 value)
void setBinary(const uint8 index, const std::vector< uint8 > &value)
void setUInt32(const uint8 index, const uint32 value)
void setNull(const uint8 index)
void setString(const uint8 index, const std::string &value)
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 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::array< uint8, SALT_LENGTH > Salt
std::vector< uint8 > Verifier
static constexpr size_t SALT_LENGTH
constexpr std::size_t size()
std::set< uint32 > RBACPermissionContainer
Battlenet::RealmHandle Id