Canonicalize usernames before rate limiting logins
authorBrian Wolff <bawolff+wn@gmail.com>
Mon, 9 May 2016 07:51:01 +0000 (03:51 -0400)
committerChad Horohoe <chadh@wikimedia.org>
Fri, 20 May 2016 16:48:36 +0000 (09:48 -0700)
Bug: T127114
Change-Id: I020cecf345c6bad4f461b70203f0bd29792de1f8

Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
includes/specials/pre-authmanager/SpecialUserlogin.php

index 4af5cf6..e745129 100644 (file)
@@ -894,7 +894,8 @@ class LoginFormPreAuthManager extends SpecialPage {
         */
        public static function incrementLoginThrottle( $username ) {
                global $wgPasswordAttemptThrottle, $wgRequest;
-               $username = User::getCanonicalName( $username, 'usable' ) ?: $username;
+               $canUsername = User::getCanonicalName( $username, 'usable' );
+               $username = $canUsername !== false ? $canUsername : $username;
 
                $throttleCount = 0;
                if ( is_array( $wgPasswordAttemptThrottle ) ) {
@@ -979,7 +980,8 @@ class LoginFormPreAuthManager extends SpecialPage {
         */
        public static function clearLoginThrottle( $username ) {
                global $wgRequest, $wgPasswordAttemptThrottle;
-               $username = User::getCanonicalName( $username, 'usable' ) ?: $username;
+               $canUsername = User::getCanonicalName( $username, 'usable' );
+               $username = $canUsername !== false ? $canUsername : $username;
 
                if ( is_array( $wgPasswordAttemptThrottle ) ) {
                        $throttleConfig = $wgPasswordAttemptThrottle;