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 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
 

Additional Inherited Members

- Protected Member Functions inherited from AccountScript
 AccountScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ AccountActionIpLogger()

AccountActionIpLogger::AccountActionIpLogger ( )
inline
49: AccountScript("AccountActionIpLogger") { }
Definition: AccountScript.h:24

Member Function Documentation

◆ AccountIPLogAction()

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

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.

54 {
56 }
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:93

References ACCOUNT_LOGIN, and AccountIPLogAction().

◆ OnEmailChange()

void AccountActionIpLogger::OnEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

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

References ACCOUNT_CHANGE_EMAIL, and AccountIPLogAction().

◆ OnFailedAccountLogin()

void AccountActionIpLogger::OnFailedAccountLogin ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

61 {
63 }

References ACCOUNT_FAIL_LOGIN, and AccountIPLogAction().

◆ OnFailedEmailChange()

void AccountActionIpLogger::OnFailedEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

86 {
88 }

References ACCOUNT_CHANGE_EMAIL_FAIL, and AccountIPLogAction().

◆ OnFailedPasswordChange()

void AccountActionIpLogger::OnFailedPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

73 {
75 }

References ACCOUNT_CHANGE_PW_FAIL, and AccountIPLogAction().

◆ OnPasswordChange()

void AccountActionIpLogger::OnPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

67 {
69 }

References ACCOUNT_CHANGE_PW, and AccountIPLogAction().