Merge "Allow extensions to indicate a username doesn't exist"
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
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' );
                }