mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-05 20:13:48 +00:00
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:
@@ -58,6 +58,33 @@ namespace AccountMgr
|
||||
return AOR_OK; // everything's fine
|
||||
}
|
||||
|
||||
AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail)
|
||||
{
|
||||
std::string username;
|
||||
|
||||
if (!GetName(accountId, username))
|
||||
{
|
||||
sScriptMgr->OnFailedEmailChange(accountId);
|
||||
return AOR_NAME_NOT_EXIST; // account doesn't exist
|
||||
}
|
||||
|
||||
if (utf8length(newEmail) > MAX_EMAIL_STR)
|
||||
{
|
||||
sScriptMgr->OnFailedEmailChange(accountId);
|
||||
return AOR_EMAIL_TOO_LONG; // email's too long
|
||||
}
|
||||
|
||||
Utf8ToUpperOnlyLatin(newEmail);
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EMAIL);
|
||||
stmt->SetData(0, newEmail);
|
||||
stmt->SetData(1, accountId);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
sScriptMgr->OnEmailChange(accountId);
|
||||
return AOR_OK;
|
||||
}
|
||||
|
||||
AccountOpResult DeleteAccount(uint32 accountId)
|
||||
{
|
||||
// Check if accounts exists
|
||||
|
||||
@@ -26,6 +26,7 @@ enum AccountOpResult
|
||||
AOR_OK,
|
||||
AOR_NAME_TOO_LONG,
|
||||
AOR_PASS_TOO_LONG,
|
||||
AOR_EMAIL_TOO_LONG,
|
||||
AOR_NAME_ALREADY_EXIST,
|
||||
AOR_NAME_NOT_EXIST,
|
||||
AOR_DB_INTERNAL_ERROR
|
||||
@@ -33,6 +34,7 @@ enum AccountOpResult
|
||||
|
||||
#define MAX_ACCOUNT_STR 20
|
||||
#define MAX_PASS_STR 16
|
||||
#define MAX_EMAIL_STR 255
|
||||
|
||||
namespace AccountMgr
|
||||
{
|
||||
@@ -40,6 +42,7 @@ namespace AccountMgr
|
||||
AccountOpResult DeleteAccount(uint32 accountId);
|
||||
AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword);
|
||||
AccountOpResult ChangePassword(uint32 accountId, std::string newPassword);
|
||||
AccountOpResult ChangeEmail(uint32 accountId, std::string email);
|
||||
bool CheckPassword(uint32 accountId, std::string password);
|
||||
|
||||
uint32 GetId(std::string const& username);
|
||||
|
||||
Reference in New Issue
Block a user