AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AccountActionIpLogger Class Reference
Inheritance diagram for AccountActionIpLogger:
AccountScript ScriptObject

Public Member Functions

 AccountActionIpLogger ()
 
void OnAccountLogin (uint32 accountId) override
 
void OnFailedAccountLogin (uint32 accountId) override
 
void OnPasswordChange (uint32 accountId) override
 
void OnFailedPasswordChange (uint32 accountId) override
 
void OnEmailChange (uint32 accountId) override
 
void OnFailedEmailChange (uint32 accountId) override
 
void AccountIPLogAction (uint32 accountId, IPLoggingTypes aType)
 
- Public Member Functions inherited from AccountScript
virtual void OnAccountLogin (uint32)
 
virtual void OnBeforeAccountDelete (uint32)
 
virtual void OnLastIpUpdate (uint32, std::string)
 
virtual void OnFailedAccountLogin (uint32)
 
virtual void OnEmailChange (uint32)
 
virtual void OnFailedEmailChange (uint32)
 
virtual void OnPasswordChange (uint32)
 
virtual void OnFailedPasswordChange (uint32)
 
virtual bool CanAccountCreateCharacter (uint32, uint8, uint8)
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Additional Inherited Members

- Protected Member Functions inherited from AccountScript
 AccountScript (const char *name, std::vector< uint16 > enabledHooks=std::vector< uint16 >())
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ AccountActionIpLogger()

AccountActionIpLogger::AccountActionIpLogger ( )
inline
48: AccountScript("AccountActionIpLogger") { }
Definition: AccountScript.h:39

Member Function Documentation

◆ AccountIPLogAction()

void AccountActionIpLogger::AccountIPLogAction ( uint32  accountId,
IPLoggingTypes  aType 
)
inline
93 {
94 if (!sWorld->getBoolConfig(CONFIG_IP_BASED_ACTION_LOGGING))
95 return;
96
97 // Action IP Logger is only intialized if config is set up
98 // Else, this script isn't loaded in the first place: We require no config check.
99
100 // We declare all the required variables
101 uint32 playerGuid = accountId;
102 uint32 characterGuid = 0;
103 std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later.
104
105 // With this switch, we change systemNote so that we have a more accurate phrasing of what type it is.
106 // Avoids Magicnumbers in SQL table
107 switch (aType)
108 {
109 case ACCOUNT_LOGIN:
110 systemNote = "Logged on Successful AccountLogin";
111 break;
113 systemNote = "Logged on Failed AccountLogin";
114 break;
116 systemNote = "Logged on Successful Account Password Change";
117 break;
119 systemNote = "Logged on Failed Account Password Change";
120 break;
122 systemNote = "Logged on Successful Account Email Change";
123 break;
125 systemNote = "Logged on Failed Account Email Change";
126 break;
127 /*case ACCOUNT_LOGOUT:
128 systemNote = "Logged on AccountLogout"; //Can not be logged
129 break;*/
130 // Neither should happen. Ever. Period. If it does, call Ghostbusters and all your local software defences to investigate.
131 case UNKNOWN_ACTION:
132 default:
133 systemNote = "ERROR! Unknown action!";
134 break;
135 }
136
137 // Once we have done everything, we can insert the new log.
138 // Seeing as the time differences should be minimal, we do not get unixtime and the timestamp right now;
139 // Rather, we let it be added with the SQL query.
140 if (aType != ACCOUNT_FAIL_LOGIN)
141 {
142 // As we can assume most account actions are NOT failed login, so this is the more accurate check.
143 // For those, we need last_ip...
145
146 stmt->SetData(0, playerGuid);
147 stmt->SetData(1, characterGuid);
148 stmt->SetData(2, aType);
149 stmt->SetData(3, playerGuid);
150 stmt->SetData(4, systemNote.c_str());
151 LoginDatabase.Execute(stmt);
152 }
153 else // ... but for failed login, we query last_attempt_ip from account table. Which we do with an unique query
154 {
156
157 stmt->SetData(0, playerGuid);
158 stmt->SetData(1, characterGuid);
159 stmt->SetData(2, aType);
160 stmt->SetData(3, playerGuid);
161 stmt->SetData(4, systemNote.c_str());
162 LoginDatabase.Execute(stmt);
163 }
164 return;
165 }
std::uint32_t uint32
Definition: Define.h:107
@ ACCOUNT_CHANGE_PW
Definition: action_ip_logger.cpp:29
@ ACCOUNT_CHANGE_EMAIL_FAIL
Definition: action_ip_logger.cpp:32
@ ACCOUNT_LOGIN
Definition: action_ip_logger.cpp:27
@ ACCOUNT_CHANGE_PW_FAIL
Definition: action_ip_logger.cpp:30
@ UNKNOWN_ACTION
Definition: action_ip_logger.cpp:42
@ ACCOUNT_CHANGE_EMAIL
Definition: action_ip_logger.cpp:31
@ ACCOUNT_FAIL_LOGIN
Definition: action_ip_logger.cpp:28
@ CONFIG_IP_BASED_ACTION_LOGGING
Definition: IWorld.h:152
@ LOGIN_INS_ALDL_IP_LOGGING
Definition: LoginDatabase.h:106
@ LOGIN_INS_FACL_IP_LOGGING
Definition: LoginDatabase.h:107
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
#define sWorld
Definition: World.h:443
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77

References ACCOUNT_CHANGE_EMAIL, ACCOUNT_CHANGE_EMAIL_FAIL, ACCOUNT_CHANGE_PW, ACCOUNT_CHANGE_PW_FAIL, ACCOUNT_FAIL_LOGIN, ACCOUNT_LOGIN, CONFIG_IP_BASED_ACTION_LOGGING, LOGIN_INS_ALDL_IP_LOGGING, LOGIN_INS_FACL_IP_LOGGING, LoginDatabase, PreparedStatementBase::SetData(), sWorld, and UNKNOWN_ACTION.

Referenced by OnAccountLogin(), OnEmailChange(), OnFailedAccountLogin(), OnFailedEmailChange(), OnFailedPasswordChange(), and OnPasswordChange().

◆ OnAccountLogin()

void AccountActionIpLogger::OnAccountLogin ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

53 {
55 }
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:92

References ACCOUNT_LOGIN, and AccountIPLogAction().

◆ OnEmailChange()

void AccountActionIpLogger::OnEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

79 {
80 AccountIPLogAction(accountId, ACCOUNT_CHANGE_EMAIL); // ... they get logged by gm command logger anyway
81 }

References ACCOUNT_CHANGE_EMAIL, and AccountIPLogAction().

◆ OnFailedAccountLogin()

void AccountActionIpLogger::OnFailedAccountLogin ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

60 {
62 }

References ACCOUNT_FAIL_LOGIN, and AccountIPLogAction().

◆ OnFailedEmailChange()

void AccountActionIpLogger::OnFailedEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

85 {
87 }

References ACCOUNT_CHANGE_EMAIL_FAIL, and AccountIPLogAction().

◆ OnFailedPasswordChange()

void AccountActionIpLogger::OnFailedPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

72 {
74 }

References ACCOUNT_CHANGE_PW_FAIL, and AccountIPLogAction().

◆ OnPasswordChange()

void AccountActionIpLogger::OnPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

66 {
68 }

References ACCOUNT_CHANGE_PW, and AccountIPLogAction().