Refactor Account & Password Length (#129)

This commit is contained in:
Meltie2013 2021-01-31 14:26:36 -06:00 committed by GitHub
parent 5a4ed6d0d6
commit 0eb525f992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -48,13 +48,18 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass
return AOR_NAME_TOO_LONG; // username's too long return AOR_NAME_TOO_LONG; // username's too long
} }
if (utf8length(password) > MAX_PASSWORD_STR)
{
return AOR_PASS_TOO_LONG; // password too long
}
normalizeString(username); normalizeString(username);
normalizeString(password); normalizeString(password);
if (GetId(username)) if (GetId(username))
{ {
{ {
return AOR_NAME_ALREADY_EXIST; // username does already exist return AOR_NAME_ALREADY_EXIST; // username does already exist
} }
} }
@ -64,7 +69,7 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass
} }
LoginDatabase.Execute("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"); LoginDatabase.Execute("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");
return AOR_OK; // everything's fine return AOR_OK; // everything's fine
} }
AccountOpResult AccountMgr::DeleteAccount(uint32 accid) AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
@ -128,7 +133,7 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname,
return AOR_NAME_TOO_LONG; return AOR_NAME_TOO_LONG;
} }
if (utf8length(new_passwd) > MAX_ACCOUNT_STR) if (utf8length(new_passwd) > MAX_PASSWORD_STR)
{ {
return AOR_PASS_TOO_LONG; return AOR_PASS_TOO_LONG;
} }
@ -157,7 +162,7 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd)
return AOR_NAME_NOT_EXIST; // account doesn't exist return AOR_NAME_NOT_EXIST; // account doesn't exist
} }
if (utf8length(new_passwd) > MAX_ACCOUNT_STR) if (utf8length(new_passwd) > MAX_PASSWORD_STR)
{ {
return AOR_PASS_TOO_LONG; return AOR_PASS_TOO_LONG;
} }

View File

@ -37,7 +37,8 @@ enum AccountOpResult
AOR_DB_INTERNAL_ERROR AOR_DB_INTERNAL_ERROR
}; };
#define MAX_ACCOUNT_STR 16 #define MAX_ACCOUNT_STR 16
#define MAX_PASSWORD_STR 16
class AccountMgr class AccountMgr
{ {
@ -61,4 +62,5 @@ class AccountMgr
}; };
#define sAccountMgr MaNGOS::Singleton<AccountMgr>::Instance() #define sAccountMgr MaNGOS::Singleton<AccountMgr>::Instance()
#endif #endif