From: Mark A. Hershberger Date: Tue, 12 Jul 2011 18:44:15 +0000 (+0000) Subject: Bug #29807 — Special:PasswordReset listed on Special:SpecialPages when Authplugin... X-Git-Tag: 1.31.0-rc.0~28902 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=eb09d10fa6dbf03a723d3ba5d9e794414f288b76;p=lhc%2Fweb%2Fwiklou.git Bug #29807 — Special:PasswordReset listed on Special:SpecialPages when Authplugin allowPasswordChange() is false After my spanking last week, I've gone over the patch more closely this time. --- diff --git a/includes/specials/SpecialPasswordReset.php b/includes/specials/SpecialPasswordReset.php index f4dbf51bea..a400940392 100644 --- a/includes/specials/SpecialPasswordReset.php +++ b/includes/specials/SpecialPasswordReset.php @@ -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