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