TrinityCore
Loading...
Searching...
No Matches
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
35
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 AccountMgr(AccountMgr const&) = delete;
62 AccountMgr& operator=(AccountMgr const&) = delete;
64
65 static AccountMgr* instance();
66
67 AccountOpResult CreateAccount(std::string username, std::string password, std::string email = "", uint32 bnetAccountId = 0, uint8 bnetIndex = 0);
68 static AccountOpResult DeleteAccount(uint32 accountId);
69 static AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword);
70 static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword);
71 static AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail);
72 static AccountOpResult ChangeRegEmail(uint32 accountId, std::string newEmail);
73 static bool CheckPassword(std::string username, std::string password);
74 static bool CheckPassword(uint32 accountId, std::string password);
75 static bool CheckEmail(uint32 accountId, std::string newEmail);
76
77 static uint32 GetId(std::string_view username);
78 static uint32 GetSecurity(uint32 accountId, int32 realmId);
79 [[nodiscard]] static QueryCallback GetSecurityAsync(uint32 accountId, int32 realmId, std::function<void(uint32)> callback);
80 static bool GetName(uint32 accountId, std::string& name);
81 static bool GetEmail(uint32 accountId, std::string& email);
82 static uint32 GetCharactersCount(uint32 accountId);
83
84 static bool IsBannedAccount(std::string const& name);
85 static bool IsPlayerAccount(uint32 gmlevel);
86 static bool IsAdminAccount(uint32 gmlevel);
87 static bool IsConsoleAccount(uint32 gmlevel);
88 static bool HasPermission(uint32 accountId, uint32 permission, uint32 realmId);
89
90 void UpdateAccountAccess(rbac::RBACData* rbac, uint32 accountId, uint8 securityLevel, int32 realmId);
91
92 void LoadRBAC();
93 rbac::RBACPermission const* GetRBACPermission(uint32 permission) const;
94
95 rbac::RBACPermissionsContainer const& GetRBACPermissionList() const { return _permissions; }
96 rbac::RBACPermissionContainer const& GetRBACDefaultPermissions(uint8 secLevel);
97
98 private:
99 void ClearRBAC();
102};
103
104#define sAccountMgr AccountMgr::instance()
105#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:129
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
Role Based Access Control related classes definition.
rbac::RBACPermissionsContainer _permissions
Definition AccountMgr.h:100
AccountMgr & operator=(AccountMgr &&)=delete
AccountMgr(AccountMgr const &)=delete
AccountMgr & operator=(AccountMgr const &)=delete
rbac::RBACDefaultPermissionsContainer _defaultPermissions
Definition AccountMgr.h:101
AccountMgr(AccountMgr &&)=delete
rbac::RBACPermissionsContainer const & GetRBACPermissionList() const
Definition AccountMgr.h:95
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