From b6f58ed41671913cc40010df584cb894d77687cf Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Fri, 24 Oct 2008 09:07:43 +0000 Subject: [PATCH] reset password attempt throttle at successful logins --- includes/specials/SpecialUserlogin.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 72c5ba9aea..813cf461b8 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -379,18 +379,20 @@ class LoginForm { } global $wgPasswordAttemptThrottle; + + $throttleCount=0; if ( is_array($wgPasswordAttemptThrottle) ) { - $key = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) ); + $throttleKey = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) ); $count = $wgPasswordAttemptThrottle['count']; $period = $wgPasswordAttemptThrottle['seconds']; global $wgMemc; - $cur = $wgMemc->get($key); - if ( !$cur ) { - $wgMemc->add( $key, 1, $period ); // start counter - } else if ( $cur < $count ) { - $wgMemc->incr($key); - } else if ( $cur >= $count ) { + $throttleCount = $wgMemc->get($throttleKey); + if ( !$throttleCount ) { + $wgMemc->add( $throttleKey, 1, $period ); // start counter + } else if ( $throttleCount < $count ) { + $wgMemc->incr($throttleKey); + } else if ( $throttleCount >= $count ) { return self::THROTTLED; } } @@ -462,6 +464,11 @@ class LoginForm { $wgAuth->updateUser( $u ); $wgUser = $u; + // Please reset throttle for successful logins, thanks! + if($throttleCount) { + $wgMemc->delete($throttleKey); + } + if ( $isAutoCreated ) { // Must be run after $wgUser is set, for correct new user log wfRunHooks( 'AuthPluginAutoCreate', array( $wgUser ) ); -- 2.20.1