X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=blobdiff_plain;f=maintenance%2FchangePassword.php;h=a550d12777431c7d342d6ffde3bc277c03585289;hb=425ee18e3b7d874d56d7644e4683171796aae024;hp=5d98e1f57e7debdeb20c5b3af0f4d4dc62d4b93c;hpb=c4d81e6c1e3d3aef7a21fbd704a94965116afebd;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index 5d98e1f57e..a550d12777 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -37,10 +37,12 @@ class ChangePassword extends Maintenance { $this->addOption( "user", "The username to operate on", false, true ); $this->addOption( "userid", "The user id to operate on", false, true ); $this->addOption( "password", "The password to use", true, true ); - $this->mDescription = "Change a user's password"; + $this->addDescription( "Change a user's password" ); } public function execute() { + global $wgDisableAuthManager; + if ( $this->hasOption( "user" ) ) { $user = User::newFromName( $this->getOption( 'user' ) ); } elseif ( $this->hasOption( "userid" ) ) { @@ -51,8 +53,20 @@ class ChangePassword extends Maintenance { if ( !$user || !$user->getId() ) { $this->error( "No such user: " . $this->getOption( 'user' ), true ); } + $password = $this->getOption( 'password' ); try { - $user->setPassword( $this->getOption( 'password' ) ); + if ( $wgDisableAuthManager ) { + $user->setPassword( $password ); + } else { + $status = $user->changeAuthenticationData( [ + 'username' => $user->getName(), + 'password' => $password, + 'retype' => $password, + ] ); + if ( !$status->isGood() ) { + throw new PasswordError( $status->getWikiText( null, null, 'en' ) ); + } + } $user->saveSettings(); $this->output( "Password set for " . $user->getName() . "\n" ); } catch ( PasswordError $pwe ) {