Use local context to get message instead of relying on global variables
[lhc/web/wiklou.git] / includes / specials / SpecialPasswordReset.php
index b07ef80..b1189ad 100644 (file)
@@ -43,14 +43,18 @@ class SpecialPasswordReset extends FormSpecialPage {
        }
 
        public function userCanExecute( User $user ) {
+               return $this->canChangePassword( $user ) === true && parent::userCanExecute( $user );
+       }
+
+       public function checkExecutePermissions( User $user ) {
                $error = $this->canChangePassword( $user );
                if ( is_string( $error ) ) {
                        throw new ErrorPageError( 'internalerror', $error );
-               } else if ( !$error ) {
+               } elseif ( !$error ) {
                        throw new ErrorPageError( 'internalerror', 'resetpass_forbidden' );
                }
 
-               return parent::userCanExecute( $user );
+               return parent::checkExecutePermissions( $user );
        }
 
        protected function getFormFields() {
@@ -276,7 +280,7 @@ class SpecialPasswordReset extends FormSpecialPage {
 
                        $this->getOutput()->addHTML( Html::rawElement( 'pre', array(), $this->email->escaped() ) );
                }
-               
+
                $this->getOutput()->addWikiMsg( 'passwordreset-emailsent' );
                $this->getOutput()->returnToMain();
        }