mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
feat(Script/Commands): allow to pass email in account create (#22310)
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
1
data/sql/updates/pending_db_world/command.sql
Normal file
1
data/sql/updates/pending_db_world/command.sql
Normal file
@@ -0,0 +1 @@
|
||||
UPDATE `command` SET `help`='Syntax: .account create $account $password $email\r\n\r\nCreate account and set password to it.\r\n$email is optional, can be left blank.' WHERE `name`='account create';
|
||||
@@ -78,7 +78,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(LOGIN_DEL_REALM_CHARACTERS, "DELETE FROM realmcharacters WHERE acctid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_REP_REALM_CHARACTERS, "REPLACE INTO realmcharacters (numchars, acctid, realmid) VALUES (?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_SEL_SUM_REALM_CHARACTERS, "SELECT SUM(numchars) FROM realmcharacters WHERE acctid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_INS_ACCOUNT, "INSERT INTO account(username, salt, verifier, expansion, joindate) VALUES(?, ?, ?, ?, NOW())", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_INS_ACCOUNT, "INSERT INTO account(username, salt, verifier, expansion, reg_mail, email, joindate) VALUES(?, ?, ?, ?, ?, ?, NOW())", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_INS_REALM_CHARACTERS_INIT, "INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist, account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_UPD_EXPANSION, "UPDATE account SET expansion = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_UPD_ACCOUNT_LOCK, "UPDATE account SET locked = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
namespace AccountMgr
|
||||
{
|
||||
|
||||
AccountOpResult CreateAccount(std::string username, std::string password)
|
||||
AccountOpResult CreateAccount(std::string username, std::string password, std::string email /*= ""*/)
|
||||
{
|
||||
if (utf8length(username) > MAX_ACCOUNT_STR)
|
||||
return AOR_NAME_TOO_LONG; // username's too long
|
||||
@@ -35,8 +35,12 @@ namespace AccountMgr
|
||||
if (utf8length(password) > MAX_PASS_STR)
|
||||
return AOR_PASS_TOO_LONG; // password's too long
|
||||
|
||||
if (utf8length(email) > MAX_EMAIL_STR)
|
||||
return AOR_EMAIL_TOO_LONG; // email is too long
|
||||
|
||||
Utf8ToUpperOnlyLatin(username);
|
||||
Utf8ToUpperOnlyLatin(password);
|
||||
Utf8ToUpperOnlyLatin(email);
|
||||
|
||||
if (GetId(username))
|
||||
return AOR_NAME_ALREADY_EXIST; // username does already exist
|
||||
@@ -48,6 +52,8 @@ namespace AccountMgr
|
||||
stmt->SetData(1, salt);
|
||||
stmt->SetData(2, verifier);
|
||||
stmt->SetData(3, uint8(sWorld->getIntConfig(CONFIG_EXPANSION)));
|
||||
stmt->SetData(4, email);
|
||||
stmt->SetData(5, email);
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ enum AccountOpResult
|
||||
|
||||
namespace AccountMgr
|
||||
{
|
||||
AccountOpResult CreateAccount(std::string username, std::string password);
|
||||
AccountOpResult CreateAccount(std::string username, std::string password, std::string email = "");
|
||||
AccountOpResult DeleteAccount(uint32 accountId);
|
||||
AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword);
|
||||
AccountOpResult ChangePassword(uint32 accountId, std::string newPassword);
|
||||
|
||||
@@ -271,10 +271,15 @@ public:
|
||||
///- %Parse the command line arguments
|
||||
char* accountName = strtok((char*)args, " ");
|
||||
char* password = strtok(nullptr, " ");
|
||||
char* email = strtok(nullptr, " ");
|
||||
|
||||
if (!accountName || !password)
|
||||
return false;
|
||||
|
||||
AccountOpResult result = AccountMgr::CreateAccount(std::string(accountName), std::string(password));
|
||||
// if email is not specified, use empty string
|
||||
std::string emailStr = email ? email : "";
|
||||
|
||||
AccountOpResult result = AccountMgr::CreateAccount(std::string(accountName), std::string(password), emailStr);
|
||||
switch (result)
|
||||
{
|
||||
case AOR_OK:
|
||||
|
||||
Reference in New Issue
Block a user