TrinityCore
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 "Realm.h"
26#include "ScriptMgr.h"
27#include "SRP6.h"
28#include "Util.h"
29#include "World.h"
30#include "WorldSession.h"
31
33
35
37{
38 ClearRBAC();
39}
40
42{
43 static AccountMgr instance;
44 return &instance;
45}
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)
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, 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 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
139
140 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT);
141 loginStmt->setUInt32(0, accountId);
142 trans->Append(loginStmt);
143
144 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
145 loginStmt->setUInt32(0, accountId);
146 trans->Append(loginStmt);
147
148 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
149 loginStmt->setUInt32(0, accountId);
150 trans->Append(loginStmt);
151
152 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_BANNED);
153 loginStmt->setUInt32(0, accountId);
154 trans->Append(loginStmt);
155
156 loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_MUTED);
157 loginStmt->setUInt32(0, accountId);
158 trans->Append(loginStmt);
159
160 LoginDatabase.CommitTransaction(trans);
161
163}
164
165AccountOpResult AccountMgr::ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword)
166{
167 // Check if accounts exists
169 stmt->setUInt32(0, accountId);
170 PreparedQueryResult result = LoginDatabase.Query(stmt);
171
172 if (!result)
174
175 if (utf8length(newUsername) > MAX_ACCOUNT_STR)
177
178 if (utf8length(newPassword) > MAX_PASS_STR)
180
181 Utf8ToUpperOnlyLatin(newUsername);
182 Utf8ToUpperOnlyLatin(newPassword);
183
184 stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_USERNAME);
185 stmt->setString(0, newUsername);
186 stmt->setUInt32(1, accountId);
187 LoginDatabase.Execute(stmt);
188
189 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(newUsername, newPassword);
190 stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGON);
191 stmt->setBinary(0, salt);
192 stmt->setBinary(1, verifier);
193 stmt->setUInt32(2, accountId);
194 LoginDatabase.Execute(stmt);
195
197}
198
199AccountOpResult AccountMgr::ChangePassword(uint32 accountId, std::string newPassword)
200{
201 std::string username;
202
203 if (!GetName(accountId, username))
204 {
205 sScriptMgr->OnFailedPasswordChange(accountId);
206 return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist
207 }
208
209 if (utf8length(newPassword) > MAX_PASS_STR)
210 {
211 sScriptMgr->OnFailedPasswordChange(accountId);
213 }
214
215 Utf8ToUpperOnlyLatin(username);
216 Utf8ToUpperOnlyLatin(newPassword);
217 auto [salt, verifier] = Trinity::Crypto::SRP6::MakeRegistrationData<AccountSRP6>(username, newPassword);
218
220 stmt->setBinary(0, salt);
221 stmt->setBinary(1, verifier);
222 stmt->setUInt32(2, accountId);
223 LoginDatabase.Execute(stmt);
224
225 sScriptMgr->OnPasswordChange(accountId);
227}
228
229AccountOpResult AccountMgr::ChangeEmail(uint32 accountId, std::string newEmail)
230{
231 std::string username;
232
233 if (!GetName(accountId, username))
234 {
235 sScriptMgr->OnFailedEmailChange(accountId);
236 return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist
237 }
238
239 if (utf8length(newEmail) > MAX_EMAIL_STR)
240 {
241 sScriptMgr->OnFailedEmailChange(accountId);
243 }
244
245 Utf8ToUpperOnlyLatin(username);
246 Utf8ToUpperOnlyLatin(newEmail);
247
249
250 stmt->setString(0, newEmail);
251 stmt->setUInt32(1, accountId);
252
253 LoginDatabase.Execute(stmt);
254
255 sScriptMgr->OnEmailChange(accountId);
257}
258
259AccountOpResult AccountMgr::ChangeRegEmail(uint32 accountId, std::string newEmail)
260{
261 std::string username;
262
263 if (!GetName(accountId, username))
264 {
265 sScriptMgr->OnFailedEmailChange(accountId);
266 return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist
267 }
268
269 if (utf8length(newEmail) > MAX_EMAIL_STR)
270 {
271 sScriptMgr->OnFailedEmailChange(accountId);
273 }
274
275 Utf8ToUpperOnlyLatin(username);
276 Utf8ToUpperOnlyLatin(newEmail);
277
279
280 stmt->setString(0, newEmail);
281 stmt->setUInt32(1, accountId);
282
283 LoginDatabase.Execute(stmt);
284
285 sScriptMgr->OnEmailChange(accountId);
287}
288
289uint32 AccountMgr::GetId(std::string_view username)
290{
292 stmt->setStringView(0, username);
293 PreparedQueryResult result = LoginDatabase.Query(stmt);
294
295 return (result) ? (*result)[0].GetUInt32() : 0;
296}
297
299{
301 stmt->setUInt32(0, accountId);
302 stmt->setInt32(1, realmId);
303 PreparedQueryResult result = LoginDatabase.Query(stmt);
304
305 return (result) ? (*result)[0].GetUInt8() : uint32(SEC_PLAYER);
306}
307
308QueryCallback AccountMgr::GetSecurityAsync(uint32 accountId, int32 realmId, std::function<void(uint32)> callback)
309{
311 stmt->setUInt32(0, accountId);
312 stmt->setInt32(1, realmId);
313 return LoginDatabase.AsyncQuery(stmt).WithPreparedCallback([callback = std::move(callback)](PreparedQueryResult result)
314 {
315 callback(result ? uint32((*result)[0].GetUInt8()) : uint32(SEC_PLAYER));
316 });
317}
318
319bool AccountMgr::GetName(uint32 accountId, std::string& name)
320{
322 stmt->setUInt32(0, accountId);
323 PreparedQueryResult result = LoginDatabase.Query(stmt);
324
325 if (result)
326 {
327 name = (*result)[0].GetString();
328 return true;
329 }
330
331 return false;
332}
333
334bool AccountMgr::GetEmail(uint32 accountId, std::string& email)
335{
337 stmt->setUInt32(0, accountId);
338 PreparedQueryResult result = LoginDatabase.Query(stmt);
339
340 if (result)
341 {
342 email = (*result)[0].GetString();
343 return true;
344 }
345
346 return false;
347}
348
349bool AccountMgr::CheckPassword(std::string username, std::string password)
350{
351 Utf8ToUpperOnlyLatin(username);
352 Utf8ToUpperOnlyLatin(password);
353
355 stmt->setString(0, username);
356
357 if (PreparedQueryResult result = LoginDatabase.Query(stmt))
358 {
359 Trinity::Crypto::SRP::Salt salt = (*result)[0].GetBinary<Trinity::Crypto::SRP::SALT_LENGTH>();
360 Trinity::Crypto::SRP::Verifier verifier = (*result)[1].GetBinary();
361 if (AccountSRP6(username, salt, verifier).CheckCredentials(username, password))
362 return true;
363 }
364
365 return false;
366}
367
368bool AccountMgr::CheckPassword(uint32 accountId, std::string password)
369{
370 std::string username;
371
372 if (!GetName(accountId, username))
373 return false;
374
375 Utf8ToUpperOnlyLatin(username);
376 Utf8ToUpperOnlyLatin(password);
377
379 stmt->setUInt32(0, accountId);
380
381 if (PreparedQueryResult result = LoginDatabase.Query(stmt))
382 {
383 Trinity::Crypto::SRP::Salt salt = (*result)[0].GetBinary<Trinity::Crypto::SRP::SALT_LENGTH>();
384 Trinity::Crypto::SRP::Verifier verifier = (*result)[1].GetBinary();
385 if (AccountSRP6(username, salt, verifier).CheckCredentials(username, password))
386 return true;
387 }
388
389 return false;
390}
391
392bool AccountMgr::CheckEmail(uint32 accountId, std::string newEmail)
393{
394 std::string oldEmail;
395
396 // We simply return false for a non-existing email
397 if (!GetEmail(accountId, oldEmail))
398 return false;
399
400 Utf8ToUpperOnlyLatin(oldEmail);
401 Utf8ToUpperOnlyLatin(newEmail);
402
403 if (strcmp(oldEmail.c_str(), newEmail.c_str()) == 0)
404 return true;
405
406 return false;
407}
408
410{
411 // check character count
413 stmt->setUInt32(0, accountId);
414 PreparedQueryResult result = CharacterDatabase.Query(stmt);
415
416 return (result) ? (*result)[0].GetUInt64() : 0;
417}
418
419bool AccountMgr::IsBannedAccount(std::string const& name)
420{
422 stmt->setString(0, name);
423 PreparedQueryResult result = LoginDatabase.Query(stmt);
424
425 if (!result)
426 return false;
427
428 return true;
429}
430
432{
433 return gmlevel == SEC_PLAYER;
434}
435
437{
438 return gmlevel >= SEC_ADMINISTRATOR && gmlevel <= SEC_CONSOLE;
439}
440
442{
443 return gmlevel == SEC_CONSOLE;
444}
445
447{
448 ClearRBAC();
449
450 TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC");
451 uint32 oldMSTime = getMSTime();
452 uint32 count1 = 0;
453 uint32 count2 = 0;
454 uint32 count3 = 0;
455
456 TC_LOG_DEBUG("rbac", "AccountMgr::LoadRBAC: Loading permissions");
457 QueryResult result = LoginDatabase.Query("SELECT id, name FROM rbac_permissions");
458 if (!result)
459 {
460 TC_LOG_INFO("server.loading", ">> Loaded 0 account permission definitions. DB table `rbac_permissions` is empty.");
461 return;
462 }
463
464 do
465 {
466 Field* field = result->Fetch();
467 uint32 id = field[0].GetUInt32();
468 _permissions[id] = new rbac::RBACPermission(id, field[1].GetString());
469 ++count1;
470 }
471 while (result->NextRow());
472
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");
475 if (!result)
476 {
477 TC_LOG_INFO("server.loading", ">> Loaded 0 linked permissions. DB table `rbac_linked_permissions` is empty.");
478 return;
479 }
480
481 uint32 permissionId = 0;
482 rbac::RBACPermission* permission = nullptr;
483
484 do
485 {
486 Field* field = result->Fetch();
487 uint32 newId = field[0].GetUInt32();
488 if (permissionId != newId)
489 {
490 permissionId = newId;
491 permission = _permissions[newId];
492 }
493
494 uint32 linkedPermissionId = field[1].GetUInt32();
495 if (linkedPermissionId == permissionId)
496 {
497 TC_LOG_ERROR("sql.sql", "RBAC Permission {} has itself as linked permission. Ignored", permissionId);
498 continue;
499 }
500 permission->AddLinkedPermission(linkedPermissionId);
501 ++count2;
502 }
503 while (result->NextRow());
504
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);
507 if (!result)
508 {
509 TC_LOG_INFO("server.loading", ">> Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty.");
510 return;
511 }
512
513 uint8 secId = 255;
514 rbac::RBACPermissionContainer* permissions = nullptr;
515 do
516 {
517 Field* field = result->Fetch();
518 uint32 newId = field[0].GetUInt32();
519 if (secId != newId || permissions == nullptr)
520 {
521 secId = newId;
522 permissions = &_defaultPermissions[secId];
523 }
524
525 permissions->insert(field[1].GetUInt32());
526 ++count3;
527 }
528 while (result->NextRow());
529
530 TC_LOG_INFO("server.loading", ">> Loaded {} permission definitions, {} linked permissions and {} default permissions in {} ms", count1, count2, count3, GetMSTimeDiffToNow(oldMSTime));
531}
532
533void AccountMgr::UpdateAccountAccess(rbac::RBACData* rbac, uint32 accountId, uint8 securityLevel, int32 realmId)
534{
535 if (rbac && securityLevel != rbac->GetSecurityLevel())
536 rbac->SetSecurityLevel(securityLevel);
537
538 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
539 // Delete old security level from DB
540 if (realmId == -1)
541 {
543 stmt->setUInt32(0, accountId);
544 trans->Append(stmt);
545 }
546 else
547 {
549 stmt->setUInt32(0, accountId);
550 stmt->setUInt32(1, realmId);
551 trans->Append(stmt);
552 }
553
554 // Add new security level
555 if (securityLevel)
556 {
558 stmt->setUInt32(0, accountId);
559 stmt->setUInt8(1, securityLevel);
560 stmt->setInt32(2, realmId);
561 trans->Append(stmt);
562 }
563
564 LoginDatabase.CommitTransaction(trans);
565}
566
568{
569 TC_LOG_TRACE("rbac", "AccountMgr::GetRBACPermission: {}", permissionId);
570 rbac::RBACPermissionsContainer::const_iterator it = _permissions.find(permissionId);
571 if (it != _permissions.end())
572 return it->second;
573
574 return nullptr;
575}
576
577bool AccountMgr::HasPermission(uint32 accountId, uint32 permissionId, uint32 realmId)
578{
579 if (!accountId)
580 {
581 TC_LOG_ERROR("rbac", "AccountMgr::HasPermission: Wrong accountId 0");
582 return false;
583 }
584
585 rbac::RBACData rbac(accountId, "", realmId, GetSecurity(accountId, realmId));
586 rbac.LoadFromDB();
587 bool hasPermission = rbac.HasPermission(permissionId);
588
589 TC_LOG_DEBUG("rbac", "AccountMgr::HasPermission [AccountId: {}, PermissionId: {}, realmId: {}]: {}",
590 accountId, permissionId, realmId, hasPermission);
591 return hasPermission;
592}
593
595{
596 for (std::pair<uint32 const, rbac::RBACPermission*>& permission : _permissions)
597 delete permission.second;
598
599 _permissions.clear();
600 _defaultPermissions.clear();
601}
602
604{
605 TC_LOG_TRACE("rbac", "AccountMgr::GetRBACDefaultPermissions: secLevel {} - size: {}", secLevel, uint32(_defaultPermissions[secLevel].size()));
606 return _defaultPermissions[secLevel];
607}
Trinity::Crypto::SRP::GruntSRP6 AccountSRP6
Definition: AccountMgr.cpp:32
#define MAX_ACCOUNT_STR
Definition: AccountMgr.h:43
#define MAX_PASS_STR
Definition: AccountMgr.h:42
#define MAX_EMAIL_STR
Definition: AccountMgr.h:44
AccountOpResult
Definition: AccountMgr.h:24
@ CHAR_DEL_CHARACTER_BAN
@ CHAR_DEL_TUTORIALS
@ CHAR_SEL_SUM_CHARS
@ CHAR_DEL_ACCOUNT_DATA
@ CHAR_SEL_CHARS_BY_ACCOUNT_ID
@ SEC_PLAYER
Definition: Common.h:40
@ SEC_ADMINISTRATOR
Definition: Common.h:43
@ SEC_CONSOLE
Definition: Common.h:44
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:153
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:159
@ LOGIN_GET_EMAIL_BY_ID
Definition: LoginDatabase.h:94
@ LOGIN_UPD_EMAIL
Definition: LoginDatabase.h:65
@ LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM
Definition: LoginDatabase.h:75
@ LOGIN_GET_ACCOUNT_ID_BY_USERNAME
Definition: LoginDatabase.h:77
@ LOGIN_UPD_REG_EMAIL
Definition: LoginDatabase.h:66
@ LOGIN_SEL_ACCOUNT_BY_ID
Definition: LoginDatabase.h:52
@ LOGIN_DEL_ACCOUNT_MUTED
@ LOGIN_DEL_ACCOUNT_BANNED
Definition: LoginDatabase.h:39
@ LOGIN_SEL_CHECK_PASSWORD_BY_NAME
Definition: LoginDatabase.h:81
@ LOGIN_DEL_ACCOUNT_ACCESS
Definition: LoginDatabase.h:74
@ LOGIN_UPD_USERNAME
Definition: LoginDatabase.h:64
@ LOGIN_GET_GMLEVEL_BY_REALMID
Definition: LoginDatabase.h:78
@ LOGIN_UPD_LOGON
Definition: LoginDatabase.h:42
@ LOGIN_GET_USERNAME_BY_ID
Definition: LoginDatabase.h:79
@ LOGIN_DEL_ACCOUNT
Definition: LoginDatabase.h:90
@ LOGIN_INS_REALM_CHARACTERS_INIT
Definition: LoginDatabase.h:59
@ LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME
Definition: LoginDatabase.h:38
@ LOGIN_INS_ACCOUNT_ACCESS
Definition: LoginDatabase.h:76
@ LOGIN_DEL_REALM_CHARACTERS
Definition: LoginDatabase.h:55
@ LOGIN_SEL_CHECK_PASSWORD
Definition: LoginDatabase.h:80
@ LOGIN_INS_ACCOUNT
Definition: LoginDatabase.h:58
#define sScriptMgr
Definition: ScriptMgr.h:1418
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:57
uint32 getMSTime()
Definition: Timer.h:33
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:795
size_t utf8length(std::string &utf8str)
Definition: Util.cpp:349
static AccountOpResult ChangeRegEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:259
void LoadRBAC()
Definition: AccountMgr.cpp:446
static AccountOpResult DeleteAccount(uint32 accountId)
Definition: AccountMgr.cpp:90
AccountOpResult CreateAccount(std::string username, std::string password, std::string email="", uint32 bnetAccountId=0, uint8 bnetIndex=0)
Definition: AccountMgr.cpp:47
rbac::RBACPermissionsContainer _permissions
Definition: AccountMgr.h:94
static AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:229
static uint32 GetSecurity(uint32 accountId, int32 realmId)
Definition: AccountMgr.cpp:298
static AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword)
Definition: AccountMgr.cpp:165
static uint32 GetCharactersCount(uint32 accountId)
Definition: AccountMgr.cpp:409
void UpdateAccountAccess(rbac::RBACData *rbac, uint32 accountId, uint8 securityLevel, int32 realmId)
Definition: AccountMgr.cpp:533
static bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:431
void ClearRBAC()
Definition: AccountMgr.cpp:594
static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
Definition: AccountMgr.cpp:199
static QueryCallback GetSecurityAsync(uint32 accountId, int32 realmId, std::function< void(uint32)> callback)
Definition: AccountMgr.cpp:308
static bool IsConsoleAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:441
static AccountMgr * instance()
Definition: AccountMgr.cpp:41
rbac::RBACPermissionContainer const & GetRBACDefaultPermissions(uint8 secLevel)
Definition: AccountMgr.cpp:603
static bool HasPermission(uint32 accountId, uint32 permission, uint32 realmId)
Definition: AccountMgr.cpp:577
static bool CheckPassword(std::string username, std::string password)
Definition: AccountMgr.cpp:349
static bool GetEmail(uint32 accountId, std::string &email)
Definition: AccountMgr.cpp:334
rbac::RBACDefaultPermissionsContainer _defaultPermissions
Definition: AccountMgr.h:95
static bool CheckEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:392
static bool IsBannedAccount(std::string const &name)
Definition: AccountMgr.cpp:419
rbac::RBACPermission const * GetRBACPermission(uint32 permission) const
Definition: AccountMgr.cpp:567
static bool IsAdminAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:436
static uint32 GetId(std::string_view username)
Definition: AccountMgr.cpp:289
static bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:319
Class used to access individual fields of database query result.
Definition: Field.h:90
uint32 GetUInt32() const
Definition: Field.cpp:62
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars=true, bool deleteFinally=false)
Definition: Player.cpp:3824
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
Definition: SRP6.cpp:54
Player session in the World.
Definition: WorldSession.h:963
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.
Definition: RBAC.h:785
Realm realm
Definition: World.cpp:3966
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
constexpr std::size_t size()
Definition: UpdateField.h:796
std::set< uint32 > RBACPermissionContainer
Definition: RBAC.h:769
Battlenet::RealmHandle Id
Definition: Realm.h:82