feat(Scripts/Commands): account set email (#19481)

* added worldserver command to set email address

* reverted sql, added Tail args

* removed pointer

* Added helper text via updatescript

* fix build

* fix build

* fixed db update

* Update data/sql/updates/db_world/2024_07_26_01.sql

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update data/sql/updates/db_world/2024_07_26_01.sql

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* fixed hander

* refactor with named params

* refactor with named params

---------

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Justin Hanley
2024-07-30 07:33:13 -06:00
committed by GitHub
parent fccfe51594
commit af6b8ce099
6 changed files with 90 additions and 1 deletions

View File

@@ -55,7 +55,8 @@ public:
{ "addon", HandleAccountSetAddonCommand, SEC_GAMEMASTER, Console::Yes },
{ "gmlevel", HandleAccountSetGmLevelCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "password", HandleAccountSetPasswordCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "2fa", HandleAccountSet2FACommand, SEC_PLAYER, Console::Yes }
{ "2fa", HandleAccountSet2FACommand, SEC_PLAYER, Console::Yes },
{ "email", HandleAccountSetEmailCommand, SEC_ADMINISTRATOR, Console::Yes }
};
static ChatCommandTable accountLockCommandTable
@@ -900,6 +901,53 @@ public:
}
return true;
}
/// Set email for account
static bool HandleAccountSetEmailCommand(ChatHandler* handler, AccountIdentifier account, std::string email, std::string emailConfirmation)
{
if (!account || !email.data() || !emailConfirmation.data())
return false;
std::string accountName = account.GetName();
if (!Utf8ToUpperOnlyLatin(accountName))
{
handler->SendErrorMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
return false;
}
uint32 targetAccountId = account.GetID();
if (!targetAccountId)
{
handler->SendErrorMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
return false;
}
if (email != emailConfirmation)
{
handler->SendErrorMessage(LANG_NEW_EMAILS_NOT_MATCH);
return false;
}
AccountOpResult result = AccountMgr::ChangeEmail(targetAccountId, email.data());
switch (result)
{
case AOR_OK:
handler->SendSysMessage(LANG_COMMAND_EMAIL);
break;
case AOR_NAME_NOT_EXIST:
handler->SendErrorMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
return false;
case AOR_EMAIL_TOO_LONG:
handler->SendErrorMessage(LANG_EMAIL_TOO_LONG);
return false;
default:
handler->SendErrorMessage(LANG_COMMAND_NOTCHANGEEMAIL);
return false;
}
return true;
}
};
void AddSC_account_commandscript()