Merge "Allow extensions to indicate a username doesn't exist"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 4 Sep 2014 22:41:27 +0000 (22:41 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 4 Sep 2014 22:41:27 +0000 (22:41 +0000)
docs/hooks.txt
includes/specials/SpecialUserlogin.php
languages/i18n/en.json
languages/i18n/qqq.json

index 4f0882e..ec2cc78 100644 (file)
@@ -863,6 +863,14 @@ $name: name of the special page, e.g. 'Watchlist'
 &$join_conds: join conditions for the tables
 $opts: FormOptions for this request
 
+'LoginUserMigrated': Called during login to allow extensions the opportunity to
+inform a user that their username doesn't exist for a specific reason, instead
+of letting the login form give the generic error message that the account does
+not exist. For example, when the account has been renamed or deleted.
+$user: the User object being authenticated against.
+&$msg: the message identifier for abort reason, or an array to pass a message
+  key and parameters.
+
 'Collation::factory': Called if $wgCategoryCollation is an unknown collation.
 $collationName: Name of the collation in question
 &$collationObject: Null. Replace with a subclass of the Collation class that
index c156a5d..845413e 100644 (file)
@@ -41,6 +41,7 @@ class LoginForm extends SpecialPage {
        const USER_BLOCKED = 11;
        const NEED_TOKEN = 12;
        const WRONG_TOKEN = 13;
+       const USER_MIGRATED = 14;
 
        /**
         * Valid error and warning messages
@@ -697,6 +698,14 @@ class LoginForm extends SpecialPage {
                }
 
                $u = User::newFromName( $this->mUsername );
+
+               // Give extensions a way to indicate the username has been updated,
+               // rather than telling the user the account doesn't exist.
+               if ( !wfRunHooks( 'LoginUserMigrated', array( $u, &$msg ) ) ) {
+                       $this->mAbortLoginErrorMsg = $msg;
+                       return self::USER_MIGRATED;
+               }
+
                if ( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
                        return self::ILLEGAL;
                }
@@ -996,6 +1005,15 @@ class LoginForm extends SpecialPage {
                                $this->mainLoginForm( $this->msg( $error,
                                                wfEscapeWikiText( $this->mUsername ) )->text() );
                                break;
+                       case self::USER_MIGRATED:
+                               $error = $this->mAbortLoginErrorMsg ?: 'login-migrated-generic';
+                               $params = array();
+                               if ( is_array( $error ) ) {
+                                       $error = array_shift( $this->mAbortLoginErrorMsg );
+                                       $params = $this->mAbortLoginErrorMsg;
+                               }
+                               $this->mainLoginForm( $this->msg( $error, $params )->text() );
+                               break;
                        default:
                                throw new MWException( 'Unhandled case value' );
                }
index e1143b5..db1325c 100644 (file)
        "createaccount-text": "Someone created an account for your email address on {{SITENAME}} ($4) named \"$2\", with password \"$3\".\nYou should log in and change your password now.\n\nYou may ignore this message, if this account was created in error.",
        "login-throttled": "You have made too many recent login attempts.\nPlease wait $1 before trying again.",
        "login-abort-generic": "Your login was unsuccessful - Aborted",
+       "login-migrated-generic": "Your account has been migrated, and your username no longer exist on this wiki.",
        "loginlanguagelabel": "Language: $1",
        "loginlanguagelinks": "* {{#language:de}}|de\n* {{#language:en}}|en\n* {{#language:eo}}|eo\n* {{#language:fr}}|fr\n* {{#language:es}}|es\n* {{#language:it}}|it\n* {{#language:nl}}|nl",
        "suspicious-userlogout": "Your request to log out was denied because it looks like it was sent by a broken browser or caching proxy.",
index 29933dc..bef8ee0 100644 (file)
        "createaccount-text": "Body of the email sent to the email address entered at [[Special:CreateAccount]] when one user creates an account for another and clicks the checkbox labelled:\n* {{msg-mw|Createaccountmail}}\n\nParameters:\n* $1 - (Unused) IP address\n* $2 - the name entered as username\n* $3 - a password (randomly generated)\n* $4 - a URL to the wiki ('<' + server name + script name + '>')\n* $5 - (Unused) number of days to password expiry date",
        "login-throttled": "Error message shown at [[Special:UserLogin]] after the user has tried to login with incorrect password too many times.\n\nThe user has to wait a certain time before trying to log in again.\n\nParameters:\n* $1 - the time to wait before the next login attempt. Automatically formatted using the following duration messages:\n** {{msg-mw|Duration-millennia}}\n** {{msg-mw|Duration-centuries}}\n** {{msg-mw|Duration-decades}}\n** {{msg-mw|Duration-years}}\n** {{msg-mw|Duration-weeks}}\n** {{msg-mw|Duration-days}}\n** {{msg-mw|Duration-hours}}\n** {{msg-mw|Duration-minutes}}\n** {{msg-mw|Duration-seconds}}\n\nThis is a protection against robots trying to find the password by trying lots of them.\nThe number of attempts and waiting time are configured via [[mw:Manual:$wgPasswordAttemptThrottle|$wgPasswordAttemptThrottle]].\nThis message is used in html.\n{{identical|Login throttled}}",
        "login-abort-generic": "The generic unsuccessful login message is used unless otherwise specified by hook writers",
+       "login-migrated-generic": "The generic unsuccessful login message when the user's account has been updated, and their username no longer exist",
        "loginlanguagelabel": "Used on [[Special:UserLogin]] if $wgLoginLanguageSelector is true. Parameters:\n* $1 - a pipe-separated list built from the names that appear in the message {{msg-mw|Loginlanguagelinks}}.\n{{Identical|Language}}",
        "loginlanguagelinks": "{{notranslate}}",
        "suspicious-userlogout": "Used when the logout request looks suspicious, in Special:UserLogout.",