TrinityCore
Loading...
Searching...
No Matches
AccountMgr.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "AccountMgr.h"
19#include "Config.h"
20#include "DatabaseEnv.h"
21#include "CryptoHash.h"
22#include "Log.h"
23#include "ObjectAccessor.h"
24#include "Player.h"
25#include "RealmList.h"
26#include "ScriptMgr.h"
27#include "SRP6.h"
28#include "Util.h"
29#include "World.h"
30#include "WorldSession.h"
31
33
35
40
46
47AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password, std::string email /*= ""*/, uint32 bnetAccountId /*= 0*/, uint8 bnetIndex /*= 0*/)
48{
49 if (utf8length(username) > MAX_ACCOUNT_STR[sWorld->getBoolConfig(CONFIG_EXTENDED_ACCOUNT_NAME_LENGTH_LIMIT)] || username.length() > MAX_ACCOUNT_NAME_BYTES)
50 return AccountOpResult::AOR_NAME_TOO_LONG; // username's too long
51
52 if (utf8length(password) > MAX_PASS_STR)
53 return AccountOpResult::AOR_PASS_TOO_LONG; // password's too long
54
55 Utf8ToUpperOnlyLatin(username);
56 Utf8ToUpperOnlyLatin(password);
58
59 if (GetId(username))
60 return AccountOpResult::AOR_NAME_ALREADY_EXIST; // username does already exist
61
63
64 stmt->setString(0, username);
65 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(username, password);
66 stmt->setBinary(1, salt);
67 stmt->setBinary(2, std::move(verifier));
68 stmt->setString(3, email);
69 stmt->setString(4, email);
70
71 if (bnetAccountId && bnetIndex)
72 {
73 stmt->setUInt32(5, bnetAccountId);
74 stmt->setUInt8(6, bnetIndex);
75 }
76 else
77 {
78 stmt->setNull(5);
79 stmt->setNull(6);
80 }
81
82 LoginDatabase.DirectExecute(stmt); // Enforce saving, otherwise AddGroup can fail
83
84 stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_REALM_CHARACTERS_INIT);
85 LoginDatabase.Execute(stmt);
86
87 return AccountOpResult::AOR_OK; // everything's fine
88}
89
91{
92 // Check if accounts exists
94 loginStmt->setUInt32(0, accountId);
95 PreparedQueryResult result = LoginDatabase.Query(loginStmt);
96
97 if (!result)
99
100 // Obtain accounts characters
102
103 stmt->setUInt32(0, accountId);
104
105 result = CharacterDatabase.Query(stmt);
106
107 if (result)
108 {
109 do
110 {
111 ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt64());
112
113 // Kick if player is online
115 {
116 WorldSession* s = p->GetSession();
117 s->KickPlayer("AccountMgr::DeleteAccount Deleting the account"); // mark session to remove at next session list update
118 s->LogoutPlayer(false); // logout player without waiting next session list update
119 }
120
121 Player::DeleteFromDB(guid, accountId, false); // no need to update realm characters
122 } while (result->NextRow());
123 }
124
125 // table realm specific but common for all characters of account for realm
126 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS);
127 stmt->setUInt32(0, accountId);
128 CharacterDatabase.Execute(stmt);
129
130 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
131 stmt->setUInt32(0, accountId);
132 CharacterDatabase.Execute(stmt);
133
134 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_BAN);
135 stmt->setUInt32(0, accountId);
136 CharacterDatabase.Execute(stmt);
137
138 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES);
139 stmt->setUInt32(0, accountId);
140 CharacterDatabase.Execute(stmt);
141
142 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
143
144 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT);
145 loginStmt->setUInt32(0, accountId);
146 trans->Append(loginStmt);
147
148 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
149 loginStmt->setUInt32(0, accountId);
150 trans->Append(loginStmt);
151
152 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
153 loginStmt->setUInt32(0, accountId);
154 trans->Append(loginStmt);
155
156 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_BANNED);
157 loginStmt->setUInt32(0, accountId);
158 trans->Append(loginStmt);
159
160 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_MUTED);
161 loginStmt->setUInt32(0, accountId);
162 trans->Append(loginStmt);
163
164 LoginDatabase.CommitTransaction(trans);
165
167}
168
169AccountOpResult AccountMgr::ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword)
170{
171 // Check if accounts exists
173 stmt->setUInt32(0, accountId);
174 PreparedQueryResult result = LoginDatabase.Query(stmt);
175
176 if (!result)
178
179 if (utf8length(newUsername) > MAX_ACCOUNT_STR[sWorld->getBoolConfig(CONFIG_EXTENDED_ACCOUNT_NAME_LENGTH_LIMIT)] || newUsername.length() > MAX_ACCOUNT_NAME_BYTES)
181
182 if (utf8length(newPassword) > MAX_PASS_STR)
184
185 Utf8ToUpperOnlyLatin(newUsername);
186 Utf8ToUpperOnlyLatin(newPassword);
187
188 stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_USERNAME);
189 stmt->setString(0, newUsername);
190 stmt->setUInt32(1, accountId);
191 LoginDatabase.Execute(stmt);
192
193 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(newUsername, newPassword);
194 stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGON);
195 stmt->setBinary(0, salt);
196 stmt->setBinary(1, std::move(verifier));
197 stmt->setUInt32(2, accountId);
198 LoginDatabase.Execute(stmt);
199
201}
202
203AccountOpResult AccountMgr::ChangePassword(uint32 accountId, std::string newPassword)
204{
205 std::string username;
206
207 if (!GetName(accountId, username))
208 {
209 sScriptMgr->OnFailedPasswordChange(accountId);
210 return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist
211 }
212
213 if (utf8length(newPassword) > MAX_PASS_STR)
214 {
215 sScriptMgr->OnFailedPasswordChange(accountId);
217 }
218
219 Utf8ToUpperOnlyLatin(username);
220 Utf8ToUpperOnlyLatin(newPassword);
221 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(username, newPassword);
222
224 stmt->setBinary(0, salt);
225 stmt->setBinary(1, std::move(verifier));
226 stmt->setUInt32(2, accountId);
227 LoginDatabase.Execute(stmt);
228
229 sScriptMgr->OnPasswordChange(accountId);
231}
232
233AccountOpResult AccountMgr::ChangeEmail(uint32 accountId, std::string newEmail)
234{
235 std::string username;
236
237 if (!GetName(accountId, username))
238 {
239 sScriptMgr->OnFailedEmailChange(accountId);
240 return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist
241 }
242
243 if (utf8length(newEmail) > MAX_EMAIL_STR)
244 {
245 sScriptMgr->OnFailedEmailChange(accountId);
247 }
248
249 Utf8ToUpperOnlyLatin(username);
250 Utf8ToUpperOnlyLatin(newEmail);
251
253
254 stmt->setString(0, newEmail);
255 stmt->setUInt32(1, accountId);
256
257 LoginDatabase.Execute(stmt);
258
259 sScriptMgr->OnEmailChange(accountId);
261}
262
263AccountOpResult AccountMgr::ChangeRegEmail(uint32 accountId, std::string newEmail)
264{
265 std::string username;
266
267 if (!GetName(accountId, username))
268 {
269 sScriptMgr->OnFailedEmailChange(accountId);
270 return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist
271 }
272
273 if (utf8length(newEmail) > MAX_EMAIL_STR)
274 {
275 sScriptMgr->OnFailedEmailChange(accountId);
277 }
278
279 Utf8ToUpperOnlyLatin(username);
280 Utf8ToUpperOnlyLatin(newEmail);
281
283
284 stmt->setString(0, newEmail);
285 stmt->setUInt32(1, accountId);
286
287 LoginDatabase.Execute(stmt);
288
289 sScriptMgr->OnEmailChange(accountId);
291}
292
293uint32 AccountMgr::GetId(std::string_view username)
294{
296 stmt->setString(0, username);
297 PreparedQueryResult result = LoginDatabase.Query(stmt);
298
299 return (result) ? (*result)[0].GetUInt32() : 0;
300}
301
303{
305 stmt->setUInt32(0, accountId);
306 stmt->setInt32(1, realmId);
307 PreparedQueryResult result = LoginDatabase.Query(stmt);
308
309 return (result) ? (*result)[0].GetUInt8() : uint32(SEC_PLAYER);
310}
311
312QueryCallback AccountMgr::GetSecurityAsync(uint32 accountId, int32 realmId, std::function<void(uint32)> callback)
313{
315 stmt->setUInt32(0, accountId);
316 stmt->setInt32(1, realmId);
317 return LoginDatabase.AsyncQuery(stmt).WithPreparedCallback([callback = std::move(callback)](PreparedQueryResult result)
318 {
319 callback(result ? uint32((*result)[0].GetUInt8()) : uint32(SEC_PLAYER));
320 });
321}
322
323bool AccountMgr::GetName(uint32 accountId, std::string& name)
324{
326 stmt->setUInt32(0, accountId);
327 PreparedQueryResult result = LoginDatabase.Query(stmt);
328
329 if (result)
330 {
331 name = (*result)[0].GetString();
332 return true;
333 }
334
335 return false;
336}
337
338bool AccountMgr::GetEmail(uint32 accountId, std::string& email)
339{
341 stmt->setUInt32(0, accountId);
342 PreparedQueryResult result = LoginDatabase.Query(stmt);
343
344 if (result)
345 {
346 email = (*result)[0].GetString();
347 return true;
348 }
349
350 return false;
351}
352
353bool AccountMgr::CheckPassword(std::string username, std::string password)
354{
355 Utf8ToUpperOnlyLatin(username);
356 Utf8ToUpperOnlyLatin(password);
357
359 stmt->setString(0, username);
360
361 if (PreparedQueryResult result = LoginDatabase.Query(stmt))
362 {
363 Trinity::Crypto::SRP::Salt salt = (*result)[0].GetBinary<Trinity::Crypto::SRP::SALT_LENGTH>();
364 Trinity::Crypto::SRP::Verifier verifier = (*result)[1].GetBinary();
365 if (AccountSRP6(username, salt, verifier).CheckCredentials(username, password))
366 return true;
367 }
368
369 return false;
370}
371
372bool AccountMgr::CheckPassword(uint32 accountId, std::string password)
373{
374 std::string username;
375
376 if (!GetName(accountId, username))
377 return false;
378
379 Utf8ToUpperOnlyLatin(username);
380 Utf8ToUpperOnlyLatin(password);
381
383 stmt->setUInt32(0, accountId);
384
385 if (PreparedQueryResult result = LoginDatabase.Query(stmt))
386 {
387 Trinity::Crypto::SRP::Salt salt = (*result)[0].GetBinary<Trinity::Crypto::SRP::SALT_LENGTH>();
388 Trinity::Crypto::SRP::Verifier verifier = (*result)[1].GetBinary();
389 if (AccountSRP6(username, salt, verifier).CheckCredentials(username, password))
390 return true;
391 }
392
393 return false;
394}
395
396bool AccountMgr::CheckEmail(uint32 accountId, std::string newEmail)
397{
398 std::string oldEmail;
399
400 // We simply return false for a non-existing email
401 if (!GetEmail(accountId, oldEmail))
402 return false;
403
404 Utf8ToUpperOnlyLatin(oldEmail);
405 Utf8ToUpperOnlyLatin(newEmail);
406
407 if (strcmp(oldEmail.c_str(), newEmail.c_str()) == 0)
408 return true;
409
410 return false;
411}
412
414{
415 // check character count
417 stmt->setUInt32(0, accountId);
418 PreparedQueryResult result = CharacterDatabase.Query(stmt);
419
420 return (result) ? (*result)[0].GetUInt64() : 0;
421}
422
423bool AccountMgr::IsBannedAccount(std::string const& name)
424{
426 stmt->setString(0, name);
427 PreparedQueryResult result = LoginDatabase.Query(stmt);
428
429 if (!result)
430 return false;
431
432 return true;
433}
434
436{
437 return gmlevel == SEC_PLAYER;
438}
439
441{
442 return gmlevel >= SEC_ADMINISTRATOR && gmlevel <= SEC_CONSOLE;
443}
444
446{
447 return gmlevel == SEC_CONSOLE;
448}
449
451{
452 ClearRBAC();
453
454 TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC");
455 uint32 oldMSTime = getMSTime();
456 uint32 count1 = 0;
457 uint32 count2 = 0;
458 uint32 count3 = 0;
459
460 TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC: Loading permissions");
461 QueryResult result = LoginDatabase.Query("SELECT id, name FROM rbac_permissions");
462 if (!result)
463 {
464 TC_LOG_INFO("server.loading", ">> Loaded 0 account permission definitions. DB table `rbac_permissions` is empty.");
465 return;
466 }
467
468 do
469 {
470 Field* field = result->Fetch();
471 uint32 id = field[0].GetUInt32();
472 _permissions[id] = new rbac::RBACPermission(id, field[1].GetString());
473 ++count1;
474 }
475 while (result->NextRow());
476
477 TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC: Loading linked permissions");
478 result = LoginDatabase.Query("SELECT id, linkedId FROM rbac_linked_permissions ORDER BY id ASC");
479 if (!result)
480 {
481 TC_LOG_INFO("server.loading", ">> Loaded 0 linked permissions. DB table `rbac_linked_permissions` is empty.");
482 return;
483 }
484
485 uint32 permissionId = 0;
486 rbac::RBACPermission* permission = nullptr;
487
488 do
489 {
490 Field* field = result->Fetch();
491 uint32 newId = field[0].GetUInt32();
492 if (permissionId != newId)
493 {
494 permissionId = newId;
495 permission = _permissions[newId];
496 }
497
498 uint32 linkedPermissionId = field[1].GetUInt32();
499 if (linkedPermissionId == permissionId)
500 {
501 TC_LOG_ERROR("sql.sql", "RBAC Permission {} has itself as linked permission. Ignored", permissionId);
502 continue;
503 }
504 permission->AddLinkedPermission(linkedPermissionId);
505 ++count2;
506 }
507 while (result->NextRow());
508
509 TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC: Loading default permissions");
510 result = LoginDatabase.PQuery("SELECT secId, permissionId FROM rbac_default_permissions WHERE (realmId = {} OR realmId = -1) ORDER BY secId ASC", sRealmList->GetCurrentRealmId().Realm);
511 if (!result)
512 {
513 TC_LOG_INFO("server.loading", ">> Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty.");
514 return;
515 }
516
517 uint8 secId = 255;
518 rbac::RBACPermissionContainer* permissions = nullptr;
519 do
520 {
521 Field* field = result->Fetch();
522 uint32 newId = field[0].GetUInt32();
523 if (secId != newId || permissions == nullptr)
524 {
525 secId = newId;
526 permissions = &_defaultPermissions[secId];
527 }
528
529 permissions->insert(field[1].GetUInt32());
530 ++count3;
531 }
532 while (result->NextRow());
533
534 TC_LOG_INFO("server.loading", ">> Loaded {} permission definitions, {} linked permissions and {} default permissions in {} ms", count1, count2, count3, GetMSTimeDiffToNow(oldMSTime));
535}
536
537void AccountMgr::UpdateAccountAccess(rbac::RBACData* rbac, uint32 accountId, uint8 securityLevel, int32 realmId)
538{
539 if (rbac && securityLevel != rbac->GetSecurityLevel())
540 rbac->SetSecurityLevel(securityLevel);
541
542 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
543 // Delete old security level from DB
544 if (realmId == -1)
545 {
547 stmt->setUInt32(0, accountId);
548 trans->Append(stmt);
549 }
550 else
551 {
553 stmt->setUInt32(0, accountId);
554 stmt->setUInt32(1, realmId);
555 trans->Append(stmt);
556 }
557
558 // Add new security level
559 if (securityLevel)
560 {
562 stmt->setUInt32(0, accountId);
563 stmt->setUInt8(1, securityLevel);
564 stmt->setInt32(2, realmId);
565 trans->Append(stmt);
566 }
567
568 LoginDatabase.CommitTransaction(trans);
569}
570
572{
573 TC_LOG_TRACE("rbac", "AccountMgr::GetRBACPermission: {}", permissionId);
574 rbac::RBACPermissionsContainer::const_iterator it = _permissions.find(permissionId);
575 if (it != _permissions.end())
576 return it->second;
577
578 return nullptr;
579}
580
581bool AccountMgr::HasPermission(uint32 accountId, uint32 permissionId, uint32 realmId)
582{
583 if (!accountId)
584 {
585 TC_LOG_ERROR("rbac", "AccountMgr::HasPermission: Wrong accountId 0");
586 return false;
587 }
588
589 rbac::RBACData rbac(accountId, "", realmId, GetSecurity(accountId, realmId));
590 rbac.LoadFromDB();
591 bool hasPermission = rbac.HasPermission(permissionId);
592
593 TC_LOG_DEBUG("rbac", "AccountMgr::HasPermission [AccountId: {}, PermissionId: {}, realmId: {}]: {}",
594 accountId, permissionId, realmId, hasPermission);
595 return hasPermission;
596}
597
599{
600 for (std::pair<uint32 const, rbac::RBACPermission*>& permission : _permissions)
601 delete permission.second;
602
603 _permissions.clear();
604 _defaultPermissions.clear();
605}
606
608{
609 TC_LOG_TRACE("rbac", "AccountMgr::GetRBACDefaultPermissions: secLevel {} - size: {}", secLevel, uint32(_defaultPermissions[secLevel].size()));
610 return _defaultPermissions[secLevel];
611}
Trinity::Crypto::SRP::GruntSRP6 AccountSRP6
constexpr std::size_t MAX_PASS_STR
Definition AccountMgr.h:45
constexpr std::size_t MAX_ACCOUNT_NAME_BYTES
Definition AccountMgr.h:44
constexpr std::size_t MAX_EMAIL_STR
Definition AccountMgr.h:46
constexpr std::size_t MAX_ACCOUNT_STR[2]
Definition AccountMgr.h:43
AccountOpResult
Definition AccountMgr.h:25
@ CHAR_DEL_CHARACTER_BAN
@ CHAR_DEL_TUTORIALS
@ CHAR_SEL_SUM_CHARS
@ CHAR_DEL_ACCOUNT_DATA
@ CHAR_SEL_CHARS_BY_ACCOUNT_ID
@ CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES
@ SEC_PLAYER
Definition Common.h:43
@ SEC_ADMINISTRATOR
Definition Common.h:46
@ SEC_CONSOLE
Definition Common.h:47
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.
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:173
#define TC_LOG_ERROR(filterType__, message__,...)
Definition Log.h:182
#define TC_LOG_INFO(filterType__, message__,...)
Definition Log.h:176
#define TC_LOG_TRACE(filterType__, message__,...)
Definition Log.h:170
@ LOGIN_GET_EMAIL_BY_ID
@ LOGIN_UPD_EMAIL
@ LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM
@ LOGIN_GET_ACCOUNT_ID_BY_USERNAME
@ LOGIN_UPD_REG_EMAIL
@ LOGIN_SEL_ACCOUNT_BY_ID
@ LOGIN_DEL_ACCOUNT_MUTED
@ LOGIN_DEL_ACCOUNT_BANNED
@ LOGIN_SEL_CHECK_PASSWORD_BY_NAME
@ LOGIN_DEL_ACCOUNT_ACCESS
@ LOGIN_UPD_USERNAME
@ LOGIN_GET_GMLEVEL_BY_REALMID
@ LOGIN_UPD_LOGON
@ LOGIN_GET_USERNAME_BY_ID
@ LOGIN_DEL_ACCOUNT
@ LOGIN_INS_REALM_CHARACTERS_INIT
@ LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME
@ LOGIN_INS_ACCOUNT_ACCESS
@ LOGIN_DEL_REALM_CHARACTERS
@ LOGIN_SEL_CHECK_PASSWORD
@ LOGIN_INS_ACCOUNT
#define sRealmList
Definition RealmList.h:95
#define sScriptMgr
Definition ScriptMgr.h:1449
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:57
uint32 getMSTime()
Definition Timer.h:33
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition Util.cpp:752
size_t utf8length(std::string &utf8str)
Definition Util.cpp:302
static AccountOpResult ChangeRegEmail(uint32 accountId, std::string newEmail)
void LoadRBAC()
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
Definition AccountMgr.h:101
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)
void ClearRBAC()
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
Definition AccountMgr.h:102
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.
Definition Field.h:94
uint32 GetUInt32() const noexcept
Definition Field.cpp:57
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars=true, bool deleteFinally=false)
Definition Player.cpp:3658
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)
bool CheckCredentials(std::string const &username, std::string const &password) const
Definition SRP6.cpp:53
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.
Definition RBAC.h:793
#define sWorld
Definition World.h:919
@ CONFIG_EXTENDED_ACCOUNT_NAME_LENGTH_LIMIT
Definition World.h:197
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
std::array< uint8, SALT_LENGTH > Salt
Definition SRP6.h:33
std::vector< uint8 > Verifier
Definition SRP6.h:35
static constexpr size_t SALT_LENGTH
Definition SRP6.h:32
std::set< uint32 > RBACPermissionContainer
Definition RBAC.h:773