From: Nemo bis Date: Mon, 19 Aug 2013 13:34:33 +0000 (+0200) Subject: Use login-throttled properly everywhere X-Git-Tag: 1.31.0-rc.0~18833 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=8d0272b2619be6d3cc2acbda393acd087ee8e405;p=lhc%2Fweb%2Fwiklou.git Use login-throttled properly everywhere Actually proper usage would probably be to split the messages. Followup to Id385be840f340476fbe7a818ff1d05154fe86d68; spotted by Shirayuki. https://translatewiki.net/wiki/Thread:Support/About_MediaWiki:Login-throttled/en Change-Id: I565971a90fc383327a51d717a80013cb7a3e9c9b --- diff --git a/includes/specials/SpecialChangeEmail.php b/includes/specials/SpecialChangeEmail.php index 816938d6e8..aab839fdfd 100644 --- a/includes/specials/SpecialChangeEmail.php +++ b/includes/specials/SpecialChangeEmail.php @@ -225,7 +225,7 @@ class SpecialChangeEmail extends UnlistedSpecialPage { * @return bool|string true or string on success, false on failure */ protected function attemptChange( User $user, $pass, $newaddr ) { - global $wgAuth; + global $wgAuth, $wgPasswordAttemptThrottle; if ( $newaddr != '' && !Sanitizer::validateEmail( $newaddr ) ) { $this->error( 'invalidemailaddress' ); @@ -235,7 +235,8 @@ class SpecialChangeEmail extends UnlistedSpecialPage { $throttleCount = LoginForm::incLoginThrottle( $user->getName() ); if ( $throttleCount === true ) { - $this->error( 'login-throttled' ); + $lang = $this->getLanguage(); + $this->error( array( 'login-throttled', $lang->formatDuration( $wgPasswordAttemptThrottle['seconds'] ) ) ); return false; } diff --git a/includes/specials/SpecialChangePassword.php b/includes/specials/SpecialChangePassword.php index 139bb6d9af..129e9193c1 100644 --- a/includes/specials/SpecialChangePassword.php +++ b/includes/specials/SpecialChangePassword.php @@ -230,6 +230,8 @@ class SpecialChangePassword extends UnlistedSpecialPage { * @throws PasswordError when cannot set the new password because requirements not met. */ protected function attemptReset( $newpass, $retype ) { + global $wgPasswordAttemptThrottle; + $isSelf = ( $this->mUserName === $this->getUser()->getName() ); if ( $isSelf ) { $user = $this->getUser(); @@ -248,7 +250,11 @@ class SpecialChangePassword extends UnlistedSpecialPage { $throttleCount = LoginForm::incLoginThrottle( $this->mUserName ); if ( $throttleCount === true ) { - throw new PasswordError( $this->msg( 'login-throttled' )->text() ); + $lang = $this->getLanguage(); + throw new PasswordError( $this->msg( 'login-throttled' ) + ->params( $lang->formatDuration( $wgPasswordAttemptThrottle['seconds'] ) ) + ->text() + ); } $abortMsg = 'resetpass-abort-generic'; diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index be58cbc41d..73c1ddff38 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -1490,10 +1490,8 @@ Parameters: * $3 - a password (randomly generated) * $4 - a URL to the wiki ('<' + server name + script name + '>') * $5 - (Unused) number of days to password expiry date", -'login-throttled' => '{{doc-important|$1 is empty, which is used in [[Special:ChangeEmail]] and [[Special:ChangePassword]].}} -Used as error message in [[Special:ChangeEmail]], [[Special:ChangePassword]], and [[Special:UserLogin]]. +'login-throttled' => 'Error message shown at [[Special:UserLogin]] after the user has tried to login with incorrect password too many times; also used by [[Special:ChangeEmail]] and [[Special:ChangePassword]]. -Error message shown at [[Special:UserLogin]] after the user has tried to login with incorrect password too many times. The user has to wait a certain time before trying to log in again. Parameters: