Bug #29807 — Special:PasswordReset listed on Special:SpecialPages when Authplugin...
authorMark A. Hershberger <mah@users.mediawiki.org>
Tue, 12 Jul 2011 18:44:15 +0000 (18:44 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Tue, 12 Jul 2011 18:44:15 +0000 (18:44 +0000)
After my spanking last week, I've gone over the patch more closely this time.

includes/specials/SpecialPasswordReset.php

index f4dbf51..a400940 100644 (file)
@@ -36,9 +36,8 @@ class SpecialPasswordReset extends FormSpecialPage {
                global $wgPasswordResetRoutes, $wgAuth;
 
                // Maybe password resets are disabled, or there are no allowable routes
-               if ( !is_array( $wgPasswordResetRoutes )
-                       || !in_array( true, array_values( $wgPasswordResetRoutes ) ) )
-               {
+               if ( !is_array( $wgPasswordResetRoutes ) ||
+                        !in_array( true, array_values( $wgPasswordResetRoutes ) ) ) {
                        throw new ErrorPageError( 'internalerror', 'passwordreset-disabled' );
                }
 
@@ -224,4 +223,31 @@ class SpecialPasswordReset extends FormSpecialPage {
                $this->getOutput()->addWikiMsg( 'passwordreset-emailsent' );
                $this->getOutput()->returnToMain();
        }
-}
+
+       /**
+        * Hide the password reset page if resets are disabled.
+        * @return Bool
+        */
+       function isListed() {
+               global $wgPasswordResetRoutes, $wgAuth;
+
+               // Maybe password resets are disabled, or there are no allowable routes
+               if ( !is_array( $wgPasswordResetRoutes ) ||
+                        !in_array( true, array_values( $wgPasswordResetRoutes ) ) ) {
+                       return false;
+               }
+
+               // Maybe the external auth plugin won't allow local password changes
+               if ( !$wgAuth->allowPasswordChange() ) {
+                       return false;
+               }
+
+               // Maybe the user is blocked (check this here rather than relying on the parent
+               // method as we have a more specific error message to use here
+               if ( $user->isBlocked() ) {
+                       return false;
+               }
+
+               return parent::isListed();
+       }
+}
\ No newline at end of file