TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
account_commandscript Class Reference

Public Member Functions

 account_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleAccountAddonCommand (ChatHandler *handler, char const *args)
 
static bool HandleAccountCreateCommand (ChatHandler *handler, char const *args)
 Create an account. More...
 
static bool HandleAccountDeleteCommand (ChatHandler *handler, char const *args)
 
static bool HandleAccountOnlineListCommand (ChatHandler *handler, char const *)
 Display info on users currently in the realm. More...
 
static bool HandleAccountLockCountryCommand (ChatHandler *handler, char const *args)
 
static bool HandleAccountLockIpCommand (ChatHandler *handler, char const *args)
 
static bool HandleAccountEmailCommand (ChatHandler *handler, char const *args)
 
static bool HandleAccountPasswordCommand (ChatHandler *handler, char const *args)
 
static bool HandleAccountCommand (ChatHandler *handler, char const *)
 
static bool HandleAccountSetAddonCommand (ChatHandler *handler, char const *args)
 Set/Unset the expansion level for an account. More...
 
static bool HandleAccountSetGmLevelCommand (ChatHandler *handler, char const *args)
 
static bool HandleAccountSetPasswordCommand (ChatHandler *handler, char const *args)
 Set password for account. More...
 
static bool HandleAccountSetEmailCommand (ChatHandler *handler, char const *args)
 Set normal email for account. More...
 
static bool HandleAccountSetRegEmailCommand (ChatHandler *handler, char const *args)
 Change registration email for account. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

account_commandscript::account_commandscript ( )
inline
34 : CommandScript("account_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> account_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

37  {
38  static std::vector<ChatCommand> accountSetSecTable =
39  {
42  };
43  static std::vector<ChatCommand> accountSetCommandTable =
44  {
46  { "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, NULL, "", accountSetSecTable },
49  };
50  static std::vector<ChatCommand> accountLockCommandTable =
51  {
54  };
55  static std::vector<ChatCommand> accountCommandTable =
56  {
62  { "lock", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK, false, NULL, "", accountLockCommandTable },
63  { "set", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET, true, NULL, "", accountSetCommandTable },
66  };
67  static std::vector<ChatCommand> commandTable =
68  {
69  { "account", rbac::RBAC_PERM_COMMAND_ACCOUNT, true, NULL, "", accountCommandTable },
70  };
71  return commandTable;
72  }
static bool HandleAccountCreateCommand(ChatHandler *handler, char const *args)
Create an account.
Definition: cs_account.cpp:107
static bool HandleAccountCommand(ChatHandler *handler, char const *)
Definition: cs_account.cpp:535
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleAccountSetPasswordCommand(ChatHandler *handler, char const *args)
Set password for account.
Definition: cs_account.cpp:741
static bool HandleAccountSetRegEmailCommand(ChatHandler *handler, char const *args)
Change registration email for account.
Definition: cs_account.cpp:881
static bool HandleAccountLockIpCommand(ChatHandler *handler, char const *args)
Definition: cs_account.cpp:320
static bool HandleAccountAddonCommand(ChatHandler *handler, char const *args)
Definition: cs_account.cpp:74
static bool HandleAccountEmailCommand(ChatHandler *handler, char const *args)
Definition: cs_account.cpp:357
static bool HandleAccountPasswordCommand(ChatHandler *handler, char const *args)
Definition: cs_account.cpp:446
Definition: RBAC.h:124
static bool HandleAccountLockCountryCommand(ChatHandler *handler, char const *args)
Definition: cs_account.cpp:270
static bool HandleAccountSetGmLevelCommand(ChatHandler *handler, char const *args)
Definition: cs_account.cpp:638
static bool HandleAccountDeleteCommand(ChatHandler *handler, char const *args)
Definition: cs_account.cpp:166
static bool HandleAccountSetAddonCommand(ChatHandler *handler, char const *args)
Set/Unset the expansion level for an account.
Definition: cs_account.cpp:575
static bool HandleAccountOnlineListCommand(ChatHandler *handler, char const *)
Display info on users currently in the realm.
Definition: cs_account.cpp:222
static bool HandleAccountSetEmailCommand(ChatHandler *handler, char const *args)
Set normal email for account.
Definition: cs_account.cpp:810

+ Here is the call graph for this function:

static bool account_commandscript::HandleAccountAddonCommand ( ChatHandler handler,
char const args 
)
inlinestatic
75  {
76  if (!*args)
77  {
79  handler->SetSentErrorMessage(true);
80  return false;
81  }
82 
83  char* exp = strtok((char*)args, " ");
84 
85  uint32 accountId = handler->GetSession()->GetAccountId();
86 
87  int expansion = atoi(exp); //get int anyway (0 if error)
88  if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
89  {
91  handler->SetSentErrorMessage(true);
92  return false;
93  }
94 
96 
97  stmt->setUInt8(0, uint8(expansion));
98  stmt->setUInt32(1, accountId);
99 
100  LoginDatabase.Execute(stmt);
101 
102  handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
103  return true;
104  }
Quat exp(const Quat &q)
Definition: Quat.h:729
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: Language.h:43
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
Definition: Language.h:94
Definition: Language.h:95
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: LoginDatabase.h:62
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: World.h:278
uint8_t uint8
Definition: g3dmath.h:164
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountCommand ( ChatHandler handler,
char const  
)
inlinestatic
536  {
537  // GM Level
538  AccountTypes gmLevel = handler->GetSession()->GetSecurity();
539  handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmLevel));
540 
541  // Security level required
542  bool hasRBAC = (handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE) ? true : false);
543  uint32 pwConfig = sWorld->getIntConfig(CONFIG_ACC_PASSCHANGESEC); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC
544 
545  handler->PSendSysMessage(LANG_ACCOUNT_SEC_TYPE, (pwConfig == PW_NONE ? "Lowest level: No Email input required." :
546  pwConfig == PW_EMAIL ? "Highest level: Email input required." :
547  pwConfig == PW_RBAC ? "Special level: Your account may require email input depending on settings. That is the case if another lien is printed." :
548  "Unknown security level: Notify technician for details."));
549 
550  // RBAC required display - is not displayed for console
551  if (pwConfig == PW_RBAC && handler->GetSession() && hasRBAC)
553 
554  // Email display if sufficient rights
556  {
557  std::string emailoutput;
558  uint32 accountId = handler->GetSession()->GetAccountId();
559 
561  stmt->setUInt32(0, accountId);
562  PreparedQueryResult result = LoginDatabase.Query(stmt);
563 
564  if (result)
565  {
566  emailoutput = (*result)[0].GetString();
567  handler->PSendSysMessage(LANG_COMMAND_EMAIL_OUTPUT, emailoutput.c_str());
568  }
569  }
570 
571  return true;
572  }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
AccountTypes GetSecurity() const
Definition: WorldSession.h:921
Definition: Language.h:865
Definition: Language.h:862
Definition: AccountMgr.h:39
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: Language.h:44
uint32_t uint32
Definition: Define.h:150
AccountTypes
Definition: Common.h:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
WorldSession * GetSession()
Definition: Chat.h:59
Definition: AccountMgr.h:40
Definition: Language.h:864
Definition: AccountMgr.h:38
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
Definition: LoginDatabase.h:99
virtual bool HasPermission(uint32 permission) const
Definition: Chat.h:100
Definition: World.h:361

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountCreateCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Create an account.

  • Parse the command line arguments
108  {
109  if (!*args)
110  return false;
111 
112  std::string email;
113 
115  char* accountName = strtok((char*)args, " ");
116  char* password = strtok(NULL, " ");
117  char* possibleEmail = strtok(NULL, " ' ");
118  if (possibleEmail)
119  email = possibleEmail;
120 
121  if (!accountName || !password)
122  return false;
123 
124  if (strchr(accountName, '@'))
125  {
127  handler->SetSentErrorMessage(true);
128  return false;
129  }
130 
131  switch (sAccountMgr->CreateAccount(std::string(accountName), std::string(password), email))
132  {
134  handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
135  if (handler->GetSession())
136  {
137  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) created Account %s (Email: '%s')",
138  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
139  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(),
140  accountName, email.c_str());
141  }
142  break;
145  handler->SetSentErrorMessage(true);
146  return false;
149  handler->SetSentErrorMessage(true);
150  return false;
153  handler->SetSentErrorMessage(true);
154  return false;
155  default:
156  handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName);
157  handler->SetSentErrorMessage(true);
158  return false;
159  }
160 
161  return true;
162  }
Definition: Language.h:877
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:875
Definition: Language.h:874
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 GetAccountId() const
Definition: WorldSession.h:922
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:873
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
#define sAccountMgr
Definition: AccountMgr.h:98
Definition: Language.h:876
Definition: Language.h:899
WorldSession * GetSession()
Definition: Chat.h:59
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountDeleteCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Delete a user account and all associated characters in this realm

Todo:
This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm then delete account)
  • Get the account name from the command line

Commands not recommended call from chat, but support anyway can delete only for account with less security This is also reject self apply in fact

167  {
168  if (!*args)
169  return false;
170 
172  char* account = strtok((char*)args, " ");
173  if (!account)
174  return false;
175 
176  std::string accountName = account;
177  if (!Utf8ToUpperOnlyLatin(accountName))
178  {
179  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
180  handler->SetSentErrorMessage(true);
181  return false;
182  }
183 
184  uint32 accountId = AccountMgr::GetId(accountName);
185  if (!accountId)
186  {
187  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
188  handler->SetSentErrorMessage(true);
189  return false;
190  }
191 
195  if (handler->HasLowerSecurityAccount(NULL, accountId, true))
196  return false;
197 
198  AccountOpResult result = AccountMgr::DeleteAccount(accountId);
199  switch (result)
200  {
202  handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName.c_str());
203  break;
205  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
206  handler->SetSentErrorMessage(true);
207  return false;
209  handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName.c_str());
210  handler->SetSentErrorMessage(true);
211  return false;
212  default:
213  handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName.c_str());
214  handler->SetSentErrorMessage(true);
215  return false;
216  }
217 
218  return true;
219  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:872
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:871
Definition: Language.h:870
AccountOpResult
Definition: AccountMgr.h:24
static uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:275
uint32_t uint32
Definition: Define.h:150
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
Definition: Chat.cpp:97
static AccountOpResult DeleteAccount(uint32 accountId)
Definition: AccountMgr.cpp:79
Definition: Language.h:412
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountEmailCommand ( ChatHandler handler,
char const args 
)
inlinestatic
358  {
359  if (!*args)
360  {
362  handler->SetSentErrorMessage(true);
363  return false;
364  }
365 
366  char* oldEmail = strtok((char*)args, " ");
367  char* password = strtok(NULL, " ");
368  char* email = strtok(NULL, " ");
369  char* emailConfirmation = strtok(NULL, " ");
370 
371  if (!oldEmail || !password || !email || !emailConfirmation)
372  {
374  handler->SetSentErrorMessage(true);
375  return false;
376  }
377 
378  if (!AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), std::string(oldEmail)))
379  {
381  sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
382  handler->SetSentErrorMessage(true);
383  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Tried to change email, but the provided email [%s] is not equal to registration email [%s].",
384  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
385  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(),
386  email, oldEmail);
387  return false;
388  }
389 
390  if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(password)))
391  {
393  sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
394  handler->SetSentErrorMessage(true);
395  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Tried to change email, but the provided password is wrong.",
396  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
397  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str());
398  return false;
399  }
400 
401  if (strcmp(email, oldEmail) == 0)
402  {
404  sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
405  handler->SetSentErrorMessage(true);
406  return false;
407  }
408 
409  if (strcmp(email, emailConfirmation) != 0)
410  {
412  sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
413  handler->SetSentErrorMessage(true);
414  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Tried to change email, but the provided password is wrong.",
415  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
416  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str());
417  return false;
418  }
419 
420 
421  AccountOpResult result = AccountMgr::ChangeEmail(handler->GetSession()->GetAccountId(), std::string(email));
422  switch (result)
423  {
426  sScriptMgr->OnEmailChange(handler->GetSession()->GetAccountId());
427  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Changed Email from [%s] to [%s].",
428  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
429  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(),
430  oldEmail, email);
431  break;
434  sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
435  handler->SetSentErrorMessage(true);
436  return false;
437  default:
439  handler->SetSentErrorMessage(true);
440  return false;
441  }
442 
443  return true;
444  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
static bool CheckPassword(uint32 accountId, std::string password)
Definition: AccountMgr.cpp:333
Definition: Language.h:859
Definition: Language.h:858
Definition: Language.h:60
Definition: Language.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: Language.h:860
Player * GetPlayer() const
Definition: WorldSession.h:927
AccountOpResult
Definition: AccountMgr.h:24
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
Definition: Language.h:856
Definition: Language.h:857
static bool CheckEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:351
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:861
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define sScriptMgr
Definition: ScriptMgr.h:837
static AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:218
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountLockCountryCommand ( ChatHandler handler,
char const args 
)
inlinestatic
271  {
272  if (!*args)
273  {
274  handler->SendSysMessage(LANG_USE_BOL);
275  handler->SetSentErrorMessage(true);
276  return false;
277  }
278  std::string param = (char*)args;
279 
280  if (!param.empty())
281  {
282  if (param == "on")
283  {
285  uint32 ip = inet_addr(handler->GetSession()->GetRemoteAddress().c_str());
287  stmt->setUInt32(0, ip);
288  PreparedQueryResult result = LoginDatabase.Query(stmt);
289  if (result)
290  {
291  Field* fields = result->Fetch();
292  std::string country = fields[0].GetString();
294  stmt->setString(0, country);
295  stmt->setUInt32(1, handler->GetSession()->GetAccountId());
296  LoginDatabase.Execute(stmt);
298  }
299  else
300  {
301  handler->PSendSysMessage("[IP2NATION] Table empty");
302  TC_LOG_DEBUG("server.bnetserver", "[IP2NATION] Table empty");
303  }
304  }
305  else if (param == "off")
306  {
308  stmt->setString(0, "00");
309  stmt->setUInt32(1, handler->GetSession()->GetAccountId());
310  LoginDatabase.Execute(stmt);
312  }
313  return true;
314  }
315  handler->SendSysMessage(LANG_USE_BOL);
316  handler->SetSentErrorMessage(true);
317  return false;
318  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Class used to access individual fields of database query result.
Definition: Field.h:56
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: Language.h:61
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void EndianConvertReverse(T &)
Definition: ByteConverter.h:49
Definition: Language.h:290
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
Definition: Language.h:62
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: LoginDatabase.h:43
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: LoginDatabase.h:64
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
std::string GetString() const
Definition: Field.h:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountLockIpCommand ( ChatHandler handler,
char const args 
)
inlinestatic
321  {
322  if (!*args)
323  {
324  handler->SendSysMessage(LANG_USE_BOL);
325  handler->SetSentErrorMessage(true);
326  return false;
327  }
328 
329  std::string param = (char*)args;
330 
331  if (!param.empty())
332  {
334 
335  if (param == "on")
336  {
337  stmt->setBool(0, true); // locked
339  }
340  else if (param == "off")
341  {
342  stmt->setBool(0, false); // unlocked
344  }
345 
346  stmt->setUInt32(1, handler->GetSession()->GetAccountId());
347 
348  LoginDatabase.Execute(stmt);
349  return true;
350  }
351 
352  handler->SendSysMessage(LANG_USE_BOL);
353  handler->SetSentErrorMessage(true);
354  return false;
355  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: Language.h:61
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void setBool(const uint8 index, const bool value)
Definition: PreparedStatement.cpp:88
Definition: Language.h:290
Definition: Language.h:62
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: LoginDatabase.h:63

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountOnlineListCommand ( ChatHandler handler,
char const  
)
inlinestatic

Display info on users currently in the realm.

  • Get the list of accounts ID logged to the realm
  • Display the list of account/characters online
  • Cycle through accounts
  • Get the username, last IP and GM level of each account
223  {
226 
228 
229  if (!result)
230  {
232  return true;
233  }
234 
239 
241  do
242  {
243  Field* fieldsDB = result->Fetch();
244  std::string name = fieldsDB[0].GetString();
245  uint32 account = fieldsDB[1].GetUInt32();
246 
248  // No SQL injection. account is uint32.
250  stmt->setUInt32(0, account);
251  PreparedQueryResult resultLogin = LoginDatabase.Query(stmt);
252 
253  if (resultLogin)
254  {
255  Field* fieldsLogin = resultLogin->Fetch();
257  fieldsLogin[0].GetCString(), name.c_str(), fieldsLogin[1].GetCString(),
258  fieldsDB[2].GetUInt16(), fieldsDB[3].GetUInt16(), fieldsLogin[3].GetUInt8(),
259  fieldsLogin[2].GetUInt8());
260  }
261  else
262  handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
263  }
264  while (result->NextRow());
265 
267  return true;
268  }
Definition: Language.h:884
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: Language.h:880
Definition: Language.h:882
Definition: PreparedStatement.h:74
char const * GetCString() const
Definition: Field.h:260
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
uint8 GetUInt8() const
Definition: Field.h:70
Definition: Language.h:879
uint32_t uint32
Definition: Define.h:150
uint16 GetUInt16() const
Definition: Field.h:108
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:375
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: LoginDatabase.h:89
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:881
std::string GetString() const
Definition: Field.h:276
Definition: Language.h:883

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountPasswordCommand ( ChatHandler handler,
char const args 
)
inlinestatic
447  {
448  // If no args are given at all, we can return false right away.
449  if (!*args)
450  {
452  handler->SetSentErrorMessage(true);
453  return false;
454  }
455 
456  // First, we check config. What security type (sec type) is it ? Depending on it, the command branches out
457  uint32 pwConfig = sWorld->getIntConfig(CONFIG_ACC_PASSCHANGESEC); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC
458 
459  // Command is supposed to be: .account password [$oldpassword] [$newpassword] [$newpasswordconfirmation] [$emailconfirmation]
460  char* oldPassword = strtok((char*)args, " "); // This extracts [$oldpassword]
461  char* newPassword = strtok(NULL, " "); // This extracts [$newpassword]
462  char* passwordConfirmation = strtok(NULL, " "); // This extracts [$newpasswordconfirmation]
463  char const* emailConfirmation = strtok(NULL, " "); // This defines the emailConfirmation variable, which is optional depending on sec type.
464  if (!emailConfirmation) // This extracts [$emailconfirmation]. If it doesn't exist, however...
465  emailConfirmation = ""; // ... it's simply "" for emailConfirmation.
466 
467  //Is any of those variables missing for any reason ? We return false.
468  if (!oldPassword || !newPassword || !passwordConfirmation)
469  {
471  handler->SetSentErrorMessage(true);
472  return false;
473  }
474 
475  // We compare the old, saved password to the entered old password - no chance for the unauthorized.
476  if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(oldPassword)))
477  {
479  sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
480  handler->SetSentErrorMessage(true);
481  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Tried to change password, but the provided old password is wrong.",
482  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
483  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str());
484  return false;
485  }
486 
487  // This compares the old, current email to the entered email - however, only...
488  if ((pwConfig == PW_EMAIL || (pwConfig == PW_RBAC && handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE))) // ...if either PW_EMAIL or PW_RBAC with the Permission is active...
489  && !AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), std::string(emailConfirmation))) // ... and returns false if the comparison fails.
490  {
492  sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
493  handler->SetSentErrorMessage(true);
494  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Tried to change password, but the entered email [%s] is wrong.",
495  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
496  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(),
497  emailConfirmation);
498  return false;
499  }
500 
501  // Making sure that newly entered password is correctly entered.
502  if (strcmp(newPassword, passwordConfirmation) != 0)
503  {
505  sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
506  handler->SetSentErrorMessage(true);
507  return false;
508  }
509 
510  // Changes password and prints result.
511  AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(newPassword));
512  switch (result)
513  {
516  sScriptMgr->OnPasswordChange(handler->GetSession()->GetAccountId());
517  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Changed Password.",
518  handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
519  handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str());
520  break;
523  sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
524  handler->SetSentErrorMessage(true);
525  return false;
526  default:
528  handler->SetSentErrorMessage(true);
529  return false;
530  }
531 
532  return true;
533  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
static bool CheckPassword(uint32 accountId, std::string password)
Definition: AccountMgr.cpp:333
Definition: Language.h:60
Definition: Language.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: AccountMgr.h:39
uint32 GetAccountId() const
Definition: WorldSession.h:922
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
Definition: Language.h:58
AccountOpResult
Definition: AccountMgr.h:24
static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
Definition: AccountMgr.cpp:180
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:856
static bool CheckEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:351
WorldSession * GetSession()
Definition: Chat.h:59
Definition: AccountMgr.h:40
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: Language.h:59
Definition: Language.h:87
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:88
virtual bool HasPermission(uint32 permission) const
Definition: Chat.h:100
Definition: World.h:361

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountSetAddonCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Set/Unset the expansion level for an account.

  • Get the command line arguments
  • Convert Account name to Upper Format
576  {
578  char* account = strtok((char*)args, " ");
579  char* exp = strtok(NULL, " ");
580 
581  if (!account)
582  return false;
583 
584  std::string accountName;
585  uint32 accountId;
586 
587  if (!exp)
588  {
589  Player* player = handler->getSelectedPlayer();
590  if (!player)
591  return false;
592 
593  accountId = player->GetSession()->GetAccountId();
594  AccountMgr::GetName(accountId, accountName);
595  exp = account;
596  }
597  else
598  {
600  accountName = account;
601  if (!Utf8ToUpperOnlyLatin(accountName))
602  {
603  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
604  handler->SetSentErrorMessage(true);
605  return false;
606  }
607 
608  accountId = AccountMgr::GetId(accountName);
609  if (!accountId)
610  {
611  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
612  handler->SetSentErrorMessage(true);
613  return false;
614  }
615  }
616 
617  // Let set addon state only for lesser (strong) security level
618  // or to self account
619  if (handler->GetSession() && handler->GetSession()->GetAccountId() != accountId &&
620  handler->HasLowerSecurityAccount(NULL, accountId, true))
621  return false;
622 
623  int expansion = atoi(exp); //get int anyway (0 if error)
624  if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
625  return false;
626 
628 
629  stmt->setUInt8(0, expansion);
630  stmt->setUInt32(1, accountId);
631 
632  LoginDatabase.Execute(stmt);
633 
634  handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion);
635  return true;
636  }
Quat exp(const Quat &q)
Definition: Quat.h:729
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
static bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:303
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: LoginDatabase.h:62
static uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:275
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:903
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
Definition: Chat.cpp:97
Definition: World.h:278
Player * getSelectedPlayer()
Definition: Chat.cpp:579
uint8_t uint8
Definition: g3dmath.h:164
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:412
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountSetEmailCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Set normal email for account.

  • Get the command line arguments

can set email only for target with less security This also restricts setting handler's own email.

811  {
812  if (!*args)
813  return false;
814 
816  char* account = strtok((char*)args, " ");
817  char* email = strtok(NULL, " ");
818  char* emailConfirmation = strtok(NULL, " ");
819 
820  if (!account || !email || !emailConfirmation)
821  {
823  handler->SetSentErrorMessage(true);
824  return false;
825  }
826 
827  std::string accountName = account;
828  if (!Utf8ToUpperOnlyLatin(accountName))
829  {
830  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
831  handler->SetSentErrorMessage(true);
832  return false;
833  }
834 
835  uint32 targetAccountId = AccountMgr::GetId(accountName);
836  if (!targetAccountId)
837  {
838  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
839  handler->SetSentErrorMessage(true);
840  return false;
841  }
842 
845  if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
846  return false;
847 
848  if (strcmp(email, emailConfirmation) != 0)
849  {
851  handler->SetSentErrorMessage(true);
852  return false;
853  }
854 
855  AccountOpResult result = AccountMgr::ChangeEmail(targetAccountId, email);
856  switch (result)
857  {
860  TC_LOG_INFO("entities.player.character", "ChangeEmail: Account %s [Id: %u] had it's email changed to %s.",
861  accountName.c_str(), targetAccountId, email);
862  break;
864  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
865  handler->SetSentErrorMessage(true);
866  return false;
869  handler->SetSentErrorMessage(true);
870  return false;
871  default:
873  handler->SetSentErrorMessage(true);
874  return false;
875  }
876 
877  return true;
878  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:859
Definition: Language.h:858
Definition: Language.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:860
AccountOpResult
Definition: AccountMgr.h:24
static uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:275
uint32_t uint32
Definition: Define.h:150
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
Definition: Chat.cpp:97
Definition: Language.h:857
Definition: Language.h:412
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
static AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:218
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountSetGmLevelCommand ( ChatHandler handler,
char const args 
)
inlinestatic
639  {
640  if (!*args)
641  {
643  handler->SetSentErrorMessage(true);
644  return false;
645  }
646 
647  std::string targetAccountName;
648  uint32 targetAccountId = 0;
649  uint32 targetSecurity = 0;
650  uint32 gm = 0;
651  char* arg1 = strtok((char*)args, " ");
652  char* arg2 = strtok(NULL, " ");
653  char* arg3 = strtok(NULL, " ");
654  bool isAccountNameGiven = true;
655 
656  if (!arg3)
657  {
658  if (!handler->getSelectedPlayer())
659  return false;
660  isAccountNameGiven = false;
661  }
662 
663  // Check for second parameter
664  if (!isAccountNameGiven && !arg2)
665  return false;
666 
667  // Check for account
668  if (isAccountNameGiven)
669  {
670  targetAccountName = arg1;
671  if (!Utf8ToUpperOnlyLatin(targetAccountName) || !AccountMgr::GetId(targetAccountName))
672  {
673  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, targetAccountName.c_str());
674  handler->SetSentErrorMessage(true);
675  return false;
676  }
677  }
678 
679  // Check for invalid specified GM level.
680  gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
681  if (gm > SEC_CONSOLE)
682  {
683  handler->SendSysMessage(LANG_BAD_VALUE);
684  handler->SetSentErrorMessage(true);
685  return false;
686  }
687 
688  // handler->getSession() == NULL only for console
689  targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
690  int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
691  uint32 playerSecurity;
692  if (handler->GetSession())
693  playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
694  else
695  playerSecurity = SEC_CONSOLE;
696 
697  // can set security level only for target with less security and to less security that we have
698  // This also restricts setting handler's own security.
699  targetSecurity = AccountMgr::GetSecurity(targetAccountId, gmRealmID);
700  if (targetSecurity >= playerSecurity || gm >= playerSecurity)
701  {
703  handler->SetSentErrorMessage(true);
704  return false;
705  }
706 
707  // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
708  if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
709  {
711 
712  stmt->setUInt32(0, targetAccountId);
713  stmt->setUInt8(1, uint8(gm));
714 
715  PreparedQueryResult result = LoginDatabase.Query(stmt);
716 
717  if (result)
718  {
720  handler->SetSentErrorMessage(true);
721  return false;
722  }
723  }
724 
725  // Check if provided realmID has a negative value other than -1
726  if (gmRealmID < -1)
727  {
729  handler->SetSentErrorMessage(true);
730  return false;
731  }
732 
733  rbac::RBACData* rbac = isAccountNameGiven ? NULL : handler->getSelectedPlayer()->GetSession()->GetRBACData();
734  sAccountMgr->UpdateAccountAccess(rbac, targetAccountId, uint8(gm), gmRealmID);
735 
736  handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
737  return true;
738  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: Language.h:399
Definition: Language.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: AccountMgr.h:47
Definition: RBAC.h:783
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: PreparedStatement.h:74
static uint32 GetSecurity(uint32 accountId)
Definition: AccountMgr.cpp:284
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: Language.h:1200
Definition: LoginDatabase.h:90
static uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:275
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
static bool IsConsoleAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:400
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
#define sAccountMgr
Definition: AccountMgr.h:98
Definition: Common.h:112
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Player * getSelectedPlayer()
Definition: Chat.cpp:579
Definition: Language.h:139
uint8_t uint8
Definition: g3dmath.h:164
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: Language.h:397
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:412
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountSetPasswordCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Set password for account.

  • Get the command line arguments

can set password only for target with less security This also restricts setting handler's own password

742  {
743  if (!*args)
744  {
746  handler->SetSentErrorMessage(true);
747  return false;
748  }
749 
751  char* account = strtok((char*)args, " ");
752  char* password = strtok(NULL, " ");
753  char* passwordConfirmation = strtok(NULL, " ");
754 
755  if (!account || !password || !passwordConfirmation)
756  return false;
757 
758  std::string accountName = account;
759  if (!Utf8ToUpperOnlyLatin(accountName))
760  {
761  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
762  handler->SetSentErrorMessage(true);
763  return false;
764  }
765 
766  uint32 targetAccountId = AccountMgr::GetId(accountName);
767  if (!targetAccountId)
768  {
769  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
770  handler->SetSentErrorMessage(true);
771  return false;
772  }
773 
776  if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
777  return false;
778 
779  if (strcmp(password, passwordConfirmation) != 0)
780  {
782  handler->SetSentErrorMessage(true);
783  return false;
784  }
785 
786  AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, password);
787 
788  switch (result)
789  {
792  break;
794  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
795  handler->SetSentErrorMessage(true);
796  return false;
799  handler->SetSentErrorMessage(true);
800  return false;
801  default:
803  handler->SetSentErrorMessage(true);
804  return false;
805  }
806  return true;
807  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:58
AccountOpResult
Definition: AccountMgr.h:24
static uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:275
static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
Definition: AccountMgr.cpp:180
uint32_t uint32
Definition: Define.h:150
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
Definition: Chat.cpp:97
Definition: Language.h:412
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Language.h:59
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
Definition: Language.h:87
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool account_commandscript::HandleAccountSetRegEmailCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Change registration email for account.

  • Get the command line arguments

can set email only for target with less security This also restricts setting handler's own email.

882  {
883  if (!*args)
884  return false;
885 
886  //- We do not want anything short of console to use this by default.
887  //- So we force that.
888  if (handler->GetSession())
889  return false;
890 
892  char* account = strtok((char*)args, " ");
893  char* email = strtok(NULL, " ");
894  char* emailConfirmation = strtok(NULL, " ");
895 
896  if (!account || !email || !emailConfirmation)
897  {
899  handler->SetSentErrorMessage(true);
900  return false;
901  }
902 
903  std::string accountName = account;
904  if (!Utf8ToUpperOnlyLatin(accountName))
905  {
906  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
907  handler->SetSentErrorMessage(true);
908  return false;
909  }
910 
911  uint32 targetAccountId = AccountMgr::GetId(accountName);
912  if (!targetAccountId)
913  {
914  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
915  handler->SetSentErrorMessage(true);
916  return false;
917  }
918 
921  if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
922  return false;
923 
924  if (strcmp(email, emailConfirmation) != 0)
925  {
927  handler->SetSentErrorMessage(true);
928  return false;
929  }
930 
931  AccountOpResult result = AccountMgr::ChangeRegEmail(targetAccountId, email);
932  switch (result)
933  {
936  TC_LOG_INFO("entities.player.character", "ChangeRegEmail: Account %s [Id: %u] had it's Registration Email changed to %s.",
937  accountName.c_str(), targetAccountId, email);
938  break;
940  handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
941  handler->SetSentErrorMessage(true);
942  return false;
945  handler->SetSentErrorMessage(true);
946  return false;
947  default:
949  handler->SetSentErrorMessage(true);
950  return false;
951  }
952 
953  return true;
954  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:859
static AccountOpResult ChangeRegEmail(uint32 accountId, std::string newEmail)
Definition: AccountMgr.cpp:248
Definition: Language.h:858
Definition: Language.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:860
AccountOpResult
Definition: AccountMgr.h:24
static uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:275
uint32_t uint32
Definition: Define.h:150
bool HasLowerSecurityAccount(WorldSession *target, uint32 account, bool strong=false)
Definition: Chat.cpp:97
Definition: Language.h:857
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:412
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: