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
47: AccountScript("AccountActionIpLogger") { }
Definition: ScriptMgr.h:1458

Member Function Documentation

◆ AccountIPLogAction()

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

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

References ACCOUNT_LOGIN, and AccountIPLogAction().

◆ OnEmailChange()

void AccountActionIpLogger::OnEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

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

References ACCOUNT_CHANGE_EMAIL, and AccountIPLogAction().

◆ OnFailedAccountLogin()

void AccountActionIpLogger::OnFailedAccountLogin ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

59 {
61 }

References ACCOUNT_FAIL_LOGIN, and AccountIPLogAction().

◆ OnFailedEmailChange()

void AccountActionIpLogger::OnFailedEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

84 {
86 }

References ACCOUNT_CHANGE_EMAIL_FAIL, and AccountIPLogAction().

◆ OnFailedPasswordChange()

void AccountActionIpLogger::OnFailedPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

71 {
73 }

References ACCOUNT_CHANGE_PW_FAIL, and AccountIPLogAction().

◆ OnPasswordChange()

void AccountActionIpLogger::OnPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

65 {
67 }

References ACCOUNT_CHANGE_PW, and AccountIPLogAction().