Remove mediawiki.special.javaScriptTest module
[lhc/web/wiklou.git] / includes / specials / SpecialPasswordReset.php
index 9e72807..292b575 100644 (file)
@@ -42,6 +42,11 @@ class SpecialPasswordReset extends FormSpecialPage {
         */
        private $result;
 
+       /**
+        * @var string $method Identifies which password reset field was specified by the user.
+        */
+       private $method;
+
        public function __construct() {
                parent::__construct( 'PasswordReset', 'editmyprivateinfo' );
        }
@@ -58,7 +63,7 @@ class SpecialPasswordReset extends FormSpecialPage {
                        throw new ErrorPageError( 'internalerror', 'resetpass_forbidden' );
                }
 
-               return parent::checkExecutePermissions( $user );
+               parent::checkExecutePermissions( $user );
        }
 
        protected function getFormFields() {
@@ -139,7 +144,7 @@ class SpecialPasswordReset extends FormSpecialPage {
         * @return bool|array
         */
        public function onSubmit( array $data ) {
-               global $wgAuth;
+               global $wgAuth, $wgMinimalPasswordLength;
 
                if ( isset( $data['Domain'] ) ) {
                        if ( $wgAuth->validDomain( $data['Domain'] ) ) {
@@ -196,6 +201,8 @@ class SpecialPasswordReset extends FormSpecialPage {
                        return array( $error );
                }
 
+               $this->method = $method;
+
                if ( count( $users ) == 0 ) {
                        if ( $method == 'email' ) {
                                // Don't reveal whether or not an email address is in use
@@ -254,7 +261,7 @@ class SpecialPasswordReset extends FormSpecialPage {
 
                $passwords = array();
                foreach ( $users as $user ) {
-                       $password = $user->randomPassword();
+                       $password = PasswordFactory::generateRandomPasswordString( $wgMinimalPasswordLength );
                        $user->setNewpassword( $password );
                        $user->saveSettings();
                        $passwords[] = $this->msg( 'passwordreset-emailelement', $user->getName(), $password )
@@ -310,7 +317,12 @@ class SpecialPasswordReset extends FormSpecialPage {
                        $this->getOutput()->addHTML( Html::rawElement( 'pre', array(), $this->email->escaped() ) );
                }
 
-               $this->getOutput()->addWikiMsg( 'passwordreset-emailsent' );
+               if ( $this->method === 'email' ) {
+                       $this->getOutput()->addWikiMsg( 'passwordreset-emailsentemail' );
+               } else {
+                       $this->getOutput()->addWikiMsg( 'passwordreset-emailsentusername' );
+               }
+
                $this->getOutput()->returnToMain();
        }