TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AccountMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _ACCMGR_H
20 #define _ACCMGR_H
21 
22 #include "RBAC.h"
23 
24 enum class AccountOpResult : uint8
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 
47 namespace rbac
48 {
49 typedef std::map<uint32, rbac::RBACPermission*> RBACPermissionsContainer;
50 typedef std::map<uint8, rbac::RBACPermissionContainer> RBACDefaultPermissionsContainer;
51 }
52 
54 {
55  private:
56  AccountMgr();
57  ~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(uint32 accountId, std::string password);
69  static bool CheckEmail(uint32 accountId, std::string newEmail);
70 
71  static uint32 GetId(std::string const& username);
72  static uint32 GetSecurity(uint32 accountId);
73  static uint32 GetSecurity(uint32 accountId, int32 realmId);
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 std::string CalculateShaPassHash(std::string const& name, std::string const& password);
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
TC_GAME_API std::string CalculateShaPassHash(std::string const &name, std::string const &password)
Definition: BattlenetAccountMgr.cpp:172
Definition: AccountMgr.h:53
rbac::RBACDefaultPermissionsContainer _defaultPermissions
Definition: AccountMgr.h:95
PasswordChangeSecurity
Definition: AccountMgr.h:36
std::map< uint8, rbac::RBACPermissionContainer > RBACDefaultPermissionsContainer
Definition: AccountMgr.h:50
Definition: AccountMgr.h:39
Definition: AccountMgr.h:47
Role Based Access Control related classes definition.
Definition: RBAC.h:783
TC_GAME_API uint32 GetId(std::string const &username)
Definition: BattlenetAccountMgr.cpp:128
std::map< uint32, rbac::RBACPermission * > RBACPermissionsContainer
Definition: AccountMgr.h:49
TC_GAME_API AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
Definition: BattlenetAccountMgr.cpp:54
AccountOpResult
Definition: AccountMgr.h:24
rbac::RBACPermissionsContainer const & GetRBACPermissionList() const
Definition: AccountMgr.h:89
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Definition: RBAC.h:748
TC_GAME_API bool CheckPassword(uint32 accountId, std::string password)
Definition: BattlenetAccountMgr.cpp:73
#define TC_GAME_API
Definition: Define.h:134
uint8_t uint8
Definition: Define.h:152
Definition: AccountMgr.h:40
Definition: AccountMgr.h:38
std::set< uint32 > RBACPermissionContainer
Definition: RBAC.h:746
rbac::RBACPermissionsContainer _permissions
Definition: AccountMgr.h:94