1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 03:06:37 +02:00

Remove some double lookups in User::BadPassword.

This commit is contained in:
Sadie Powell
2025-04-24 11:51:37 +01:00
parent 36d69b1e5c
commit 1630ccedb1
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -833,14 +833,17 @@ Anope::string User::Mask() const
bool User::BadPassword()
{
if (!Config->GetBlock("options").Get<unsigned int>("badpasslimit"))
const auto badpasslimit = Config->GetBlock("options").Get<unsigned>("badpasslimit");
if (!badpasslimit)
return false;
if (Config->GetBlock("options").Get<time_t>("badpasstimeout") > 0 && this->invalid_pw_time > 0 && this->invalid_pw_time < Anope::CurTime - Config->GetBlock("options").Get<time_t>("badpasstimeout"))
const auto badpasstimeout = Config->GetBlock("options").Get<time_t>("badpasstimeout");
if (badpasstimeout > 0 && this->invalid_pw_time > 0 && this->invalid_pw_time < Anope::CurTime - badpasstimeout)
this->invalid_pw_count = 0;
++this->invalid_pw_count;
this->invalid_pw_time = Anope::CurTime;
if (this->invalid_pw_count >= Config->GetBlock("options").Get<unsigned int>("badpasslimit"))
if (this->invalid_pw_count >= badpasslimit)
{
this->Kill(Me, "Too many invalid passwords");
return true;