Index: trunk/phase3/includes/specials/SpecialPasswordReset.php |
— | — | @@ -35,23 +35,13 @@ |
36 | 36 | public function userCanExecute( User $user ) { |
37 | 37 | global $wgPasswordResetRoutes, $wgAuth; |
38 | 38 | |
39 | | - // Maybe password resets are disabled, or there are no allowable routes |
40 | | - if ( !is_array( $wgPasswordResetRoutes ) || |
41 | | - !in_array( true, array_values( $wgPasswordResetRoutes ) ) ) { |
42 | | - throw new ErrorPageError( 'internalerror', 'passwordreset-disabled' ); |
43 | | - } |
44 | | - |
45 | | - // Maybe the external auth plugin won't allow local password changes |
46 | | - if ( !$wgAuth->allowPasswordChange() ) { |
| 39 | + $error = $this->canChangePassword( $user ); |
| 40 | + if ( is_string( $error ) ) { |
| 41 | + throw new ErrorPageError( 'internalerror', $error ); |
| 42 | + } else if ( !$error ) { |
47 | 43 | throw new ErrorPageError( 'internalerror', 'resetpass_forbidden' ); |
48 | 44 | } |
49 | 45 | |
50 | | - // Maybe the user is blocked (check this here rather than relying on the parent |
51 | | - // method as we have a more specific error message to use here |
52 | | - if ( $user->isBlocked() ) { |
53 | | - throw new ErrorPageError( 'internalerror', 'blocked-mailpassword' ); |
54 | | - } |
55 | | - |
56 | 46 | return parent::userCanExecute( $user ); |
57 | 47 | } |
58 | 48 | |
— | — | @@ -224,30 +214,41 @@ |
225 | 215 | $this->getOutput()->returnToMain(); |
226 | 216 | } |
227 | 217 | |
228 | | - /** |
229 | | - * Hide the password reset page if resets are disabled. |
230 | | - * @return Bool |
231 | | - */ |
232 | | - function isListed() { |
| 218 | + function canChangePassword(User $user) { |
233 | 219 | global $wgPasswordResetRoutes, $wgAuth; |
234 | 220 | |
235 | 221 | // Maybe password resets are disabled, or there are no allowable routes |
236 | 222 | if ( !is_array( $wgPasswordResetRoutes ) || |
237 | 223 | !in_array( true, array_values( $wgPasswordResetRoutes ) ) ) { |
238 | | - return false; |
| 224 | + return 'passwordreset-disabled'; |
239 | 225 | } |
240 | 226 | |
241 | 227 | // Maybe the external auth plugin won't allow local password changes |
242 | 228 | if ( !$wgAuth->allowPasswordChange() ) { |
243 | | - return false; |
| 229 | + return 'resetpass_forbidden'; |
244 | 230 | } |
245 | 231 | |
246 | 232 | // Maybe the user is blocked (check this here rather than relying on the parent |
247 | 233 | // method as we have a more specific error message to use here |
248 | 234 | if ( $user->isBlocked() ) { |
249 | | - return false; |
| 235 | + return 'blocked-mailpassword'; |
250 | 236 | } |
251 | 237 | |
252 | | - return parent::isListed(); |
| 238 | + return true; |
253 | 239 | } |
| 240 | + |
| 241 | + |
| 242 | + /** |
| 243 | + * Hide the password reset page if resets are disabled. |
| 244 | + * @return Bool |
| 245 | + */ |
| 246 | + function isListed() { |
| 247 | + global $wgPasswordResetRoutes, $wgAuth, $wgUser; |
| 248 | + |
| 249 | + if ( $this->canChangePassword( $wgUser ) === true ) { |
| 250 | + return parent::isListed(); |
| 251 | + } |
| 252 | + |
| 253 | + return false; |
| 254 | + } |
254 | 255 | } |
\ No newline at end of file |