X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fauth%2FThrottlePreAuthenticationProvider.php;h=ae0bc6bb7763fd4fa43dc9a3974d5f36d42c953c;hb=288fb8cafaa14e5bacda9316536f36fe4425b8a4;hp=e2123efa619766c9be4917c055cad2696796fd2f;hpb=58dab5a2dc516c82fc9ef367e9a1defaab8d99b6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/auth/ThrottlePreAuthenticationProvider.php b/includes/auth/ThrottlePreAuthenticationProvider.php index e2123efa61..ae0bc6bb77 100644 --- a/includes/auth/ThrottlePreAuthenticationProvider.php +++ b/includes/auth/ThrottlePreAuthenticationProvider.php @@ -65,13 +65,19 @@ class ThrottlePreAuthenticationProvider extends AbstractPreAuthenticationProvide public function setConfig( Config $config ) { parent::setConfig( $config ); + $accountCreationThrottle = $this->config->get( 'AccountCreationThrottle' ); + // Handle old $wgAccountCreationThrottle format (number of attempts per 24 hours) + if ( !is_array( $accountCreationThrottle ) ) { + $accountCreationThrottle = [ [ + 'count' => $accountCreationThrottle, + 'seconds' => 86400, + ] ]; + } + // @codeCoverageIgnoreStart $this->throttleSettings += [ // @codeCoverageIgnoreEnd - 'accountCreationThrottle' => [ [ - 'count' => $this->config->get( 'AccountCreationThrottle' ), - 'seconds' => 86400, - ] ], + 'accountCreationThrottle' => $accountCreationThrottle, 'passwordAttemptThrottle' => $this->config->get( 'PasswordAttemptThrottle' ), ]; @@ -107,7 +113,9 @@ class ThrottlePreAuthenticationProvider extends AbstractPreAuthenticationProvide $result = $this->accountCreationThrottle->increase( null, $ip, __METHOD__ ); if ( $result ) { - return \StatusValue::newFatal( 'acct_creation_throttle_hit', $result['count'] ); + $message = wfMessage( 'acct_creation_throttle_hit' )->params( $result['count'] ) + ->durationParams( $result['wait'] ); + return \StatusValue::newFatal( $message ); } return \StatusValue::newGood(); @@ -159,7 +167,9 @@ class ThrottlePreAuthenticationProvider extends AbstractPreAuthenticationProvide $data = $this->manager->getAuthenticationSessionData( 'LoginThrottle' ); if ( !$data ) { - $this->logger->error( 'throttler data not found for {user}', [ 'user' => $user->getName() ] ); + // this can occur when login is happening via AuthenticationRequest::$loginRequest + // so testForAuthentication is skipped + $this->logger->info( 'throttler data not found for {user}', [ 'user' => $user->getName() ] ); return; }