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,6 +48,11 @@ 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);
@ -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

@ -38,6 +38,7 @@ enum AccountOpResult
}; };
#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