diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-12-23 20:51:53 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-12-23 20:51:53 +0100 |
| commit | e05541665b67e55c4ff70073854886df1222643d (patch) | |
| tree | b09e44276e6ee04f6570a1f1ec7e0db0ae13b9b3 /src/server/game | |
| parent | a83673c4192c9dd2a67ab45f0d65cf451fcfcb6f (diff) | |
Core/Accounts: Migrate RA credentials checking to use AccountMgr instead of copying its logic
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/Accounts/AccountMgr.cpp | 19 | ||||
| -rw-r--r-- | src/server/game/Accounts/AccountMgr.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index bae151cd1b6..0229dd686b4 100644 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -344,6 +344,25 @@ bool AccountMgr::GetEmail(uint32 accountId, std::string& email) return false; } +bool AccountMgr::CheckPassword(std::string username, std::string password) +{ + Utf8ToUpperOnlyLatin(username); + Utf8ToUpperOnlyLatin(password); + + LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_CHECK_PASSWORD_BY_NAME); + stmt->setString(0, username); + + if (PreparedQueryResult result = LoginDatabase.Query(stmt)) + { + Trinity::Crypto::SRP6::Salt salt = (*result)[0].GetBinary<Trinity::Crypto::SRP6::SALT_LENGTH>(); + Trinity::Crypto::SRP6::Verifier verifier = (*result)[1].GetBinary<Trinity::Crypto::SRP6::VERIFIER_LENGTH>(); + if (Trinity::Crypto::SRP6::CheckLogin(username, password, salt, verifier)) + return true; + } + + return false; +} + bool AccountMgr::CheckPassword(uint32 accountId, std::string password) { std::string username; diff --git a/src/server/game/Accounts/AccountMgr.h b/src/server/game/Accounts/AccountMgr.h index 9e28396df06..ce881bd49a9 100644 --- a/src/server/game/Accounts/AccountMgr.h +++ b/src/server/game/Accounts/AccountMgr.h @@ -64,6 +64,7 @@ class TC_GAME_API AccountMgr static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword); static AccountOpResult ChangeEmail(uint32 accountId, std::string newEmail); static AccountOpResult ChangeRegEmail(uint32 accountId, std::string newEmail); + static bool CheckPassword(std::string username, std::string password); static bool CheckPassword(uint32 accountId, std::string password); static bool CheckEmail(uint32 accountId, std::string newEmail); |
