Use login-throttled properly everywhere
authorNemo bis <federicoleva@tiscali.it>
Mon, 19 Aug 2013 13:34:33 +0000 (15:34 +0200)
committerNikerabbit <niklas.laxstrom@gmail.com>
Sun, 1 Sep 2013 09:39:59 +0000 (09:39 +0000)
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

includes/specials/SpecialChangeEmail.php
includes/specials/SpecialChangePassword.php
languages/messages/MessagesQqq.php

index 816938d..aab839f 100644 (file)
@@ -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;
                }
index 139bb6d..129e919 100644 (file)
@@ -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';
index be58cbc..73c1ddf 100644 (file)
@@ -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|<code>$1</code> 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: