aboutsummaryrefslogtreecommitdiff
path: root/src/command_parse.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-02-28 14:30:35 +0000
committerGravatar Sadie Powell2023-02-28 14:38:44 +0000
commit1c6d20e73c9369eb57b255188b59d784d0f2730e (patch)
treecd80f50659a8e78b609daee90791f95e3da174e5 /src/command_parse.cpp
parentFix some unnecessary boolean explicit checks. (diff)
Refactor the password checking API.
- Rename from (On)PassCompare to (On)CheckPassword. - Fix the order of the arguments to be password, hash, value. This makes more sense than what it was previously. - Fix the code documentation to not be complete nonsense and not reference ancient outdated APIs.
Diffstat (limited to 'src/command_parse.cpp')
-rw-r--r--src/command_parse.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 0460f60b7..a5edf9913 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -26,24 +26,24 @@
#include "inspircd.h"
-bool InspIRCd::PassCompare(const std::string& data, const std::string& input, const std::string& hashtype)
+bool InspIRCd::CheckPassword(const std::string& password, const std::string& passwordhash, const std::string& value)
{
ModResult res;
- FIRST_MOD_RESULT(OnPassCompare, res, (data, input, hashtype));
+ FIRST_MOD_RESULT(OnCheckPassword, res, (password, passwordhash, value));
- /* Module matched */
if (res == MOD_RES_ALLOW)
- return true;
+ return true; // Password explicitly valid.
- /* Module explicitly didnt match */
if (res == MOD_RES_DENY)
- return false;
+ return false; // Password explicitly invalid.
- /* We dont handle any hash types except for plaintext - Thanks tra26 */
- if (!hashtype.empty() && !stdalgo::string::equalsci(hashtype, "plaintext"))
- return false;
+ // The hash algorithm wasn't recognised by any modules. If its plain
+ // text then we can check it internally.
+ if (passwordhash.empty() || stdalgo::string::equalsci(passwordhash, "plaintext"))
+ return TimingSafeCompare(password, value);
- return TimingSafeCompare(data, input);
+ // The password was invalid.
+ return false;
}
bool CommandParser::LoopCall(User* user, Command* handler, const CommandBase::Params& parameters, unsigned int splithere, int extra, bool usemax)