X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FresetUserEmail.php;h=d6b4b7905d51da539447cd0be9342dd16a41fe37;hb=e69bcfad17d67da5113cdd75276a5f7b5cefb123;hp=816e8a430bf8ff99ce7fb64d3defb9efe283eba0;hpb=74174fca253b9a759d7402f09b7fc37d5de0e9be;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/resetUserEmail.php b/maintenance/resetUserEmail.php index 816e8a430b..d6b4b7905d 100644 --- a/maintenance/resetUserEmail.php +++ b/maintenance/resetUserEmail.php @@ -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(); } @@ -45,22 +48,25 @@ class ResetUserEmail extends Maintenance { $user = User::newFromName( $userName ); } if ( !$user || !$user->getId() || !$user->loadFromId() ) { - $this->error( "Error: user '$userName' does not exist\n", 1 ); + $this->fatalError( "Error: user '$userName' does not exist\n" ); } $email = $this->getArg( 1 ); if ( !Sanitizer::validateEmail( $email ) ) { - $this->error( "Error: email '$email' is not valid\n", 1 ); + $this->fatalError( "Error: email '$email' is not valid\n" ); } // Code from https://wikitech.wikimedia.org/wiki/Password_reset $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 ) ); + } } } -$maintClass = 'ResetUserEmail'; +$maintClass = ResetUserEmail::class; require_once RUN_MAINTENANCE_IF_MAIN;