TrinityCore
AccountMgr.h
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#ifndef _ACCMGR_H
19#define _ACCMGR_H
20
21#include "RBAC.h"
22
24{
25 AOR_OK,
33};
34
36{
40};
41
42#define MAX_PASS_STR 16
43#define MAX_ACCOUNT_STR 16
44#define MAX_EMAIL_STR 64
45
46namespace rbac
47{
48typedef std::map<uint32, rbac::RBACPermission*> RBACPermissionsContainer;
49typedef std::map<uint8, rbac::RBACPermissionContainer> RBACDefaultPermissionsContainer;
50}
51
53{
54 private:
55 AccountMgr();
57
58 public:
59 static AccountMgr* instance();
60
61 AccountOpResult CreateAccount(std::string username, std::string password, std::string email = "", uint32 bnetAccountId = 0, uint8 bnetIndex = 0);
62 static AccountOpResult DeleteAccount(uint32 accountId);
63 static AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword);
64 static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword);
65 static AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail);
66 static AccountOpResult ChangeRegEmail(uint32 accountId, std::string newEmail);
67 static bool CheckPassword(std::string username, std::string password);
68 static bool CheckPassword(uint32 accountId, std::string password);
69 static bool CheckEmail(uint32 accountId, std::string newEmail);
70
71 static uint32 GetId(std::string_view username);
72 static uint32 GetSecurity(uint32 accountId, int32 realmId);
73 [[nodiscard]] static QueryCallback GetSecurityAsync(uint32 accountId, int32 realmId, std::function<void(uint32)> callback);
74 static bool GetName(uint32 accountId, std::string& name);
75 static bool GetEmail(uint32 accountId, std::string& email);
76 static uint32 GetCharactersCount(uint32 accountId);
77
78 static bool IsBannedAccount(std::string const& name);
79 static bool IsPlayerAccount(uint32 gmlevel);
80 static bool IsAdminAccount(uint32 gmlevel);
81 static bool IsConsoleAccount(uint32 gmlevel);
82 static bool HasPermission(uint32 accountId, uint32 permission, uint32 realmId);
83
84 void UpdateAccountAccess(rbac::RBACData* rbac, uint32 accountId, uint8 securityLevel, int32 realmId);
85
86 void LoadRBAC();
87 rbac::RBACPermission const* GetRBACPermission(uint32 permission) const;
88
89 rbac::RBACPermissionsContainer const& GetRBACPermissionList() const { return _permissions; }
90 rbac::RBACPermissionContainer const& GetRBACDefaultPermissions(uint8 secLevel);
91
92 private:
93 void ClearRBAC();
96};
97
98#define sAccountMgr AccountMgr::instance()
99#endif
PasswordChangeSecurity
Definition: AccountMgr.h:36
@ PW_EMAIL
Definition: AccountMgr.h:38
@ PW_RBAC
Definition: AccountMgr.h:39
@ PW_NONE
Definition: AccountMgr.h:37
AccountOpResult
Definition: AccountMgr.h:24
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
Role Based Access Control related classes definition.
rbac::RBACPermissionsContainer _permissions
Definition: AccountMgr.h:94
rbac::RBACDefaultPermissionsContainer _defaultPermissions
Definition: AccountMgr.h:95
rbac::RBACPermissionsContainer const & GetRBACPermissionList() const
Definition: AccountMgr.h:89
TC_GAME_API AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
TC_GAME_API uint32 GetId(std::string_view username)
TC_GAME_API bool CheckPassword(uint32 accountId, std::string password)
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
std::map< uint32, rbac::RBACPermission * > RBACPermissionsContainer
Definition: AccountMgr.h:48
std::map< uint8, rbac::RBACPermissionContainer > RBACDefaultPermissionsContainer
Definition: AccountMgr.h:49
std::set< uint32 > RBACPermissionContainer
Definition: RBAC.h:769