Merge "resetUserEmail: Allow resetting email without scrambling password"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 18 Mar 2016 22:04:52 +0000 (22:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 18 Mar 2016 22:04:52 +0000 (22:04 +0000)
maintenance/resetUserEmail.php

index 816e8a4..8d0873f 100644 (file)
@@ -34,6 +34,9 @@ class ResetUserEmail extends Maintenance {
                $this->addDescription( "Resets a user's email" );
                $this->addArg( 'user', 'Username or user ID, if starts with #', true );
                $this->addArg( 'email', 'Email to assign' );
+
+               $this->addOption( 'no-reset-password', 'Don\'t reset the user\'s password', false, false );
+
                parent::__construct();
        }
 
@@ -57,8 +60,11 @@ class ResetUserEmail extends Maintenance {
                $user->setEmail( $email );
                $user->setEmailAuthenticationTimestamp( wfTimestampNow() );
                $user->saveSettings();
-               // Kick whomever is currently controlling the account off
-               $user->setPassword( PasswordFactory::generateRandomPasswordString( 128 ) );
+
+               if ( !$this->hasOption( 'no-reset-password' ) ) {
+                       // Kick whomever is currently controlling the account off
+                       $user->setPassword( PasswordFactory::generateRandomPasswordString( 128 ) );
+               }
        }
 }