X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=blobdiff_plain;f=maintenance%2FchangePassword.php;h=a550d12777431c7d342d6ffde3bc277c03585289;hb=425ee18e3b7d874d56d7644e4683171796aae024;hp=8687f81410c5673f065eb3b5d99419ea7eb4360d;hpb=e2a7988178698b4369c7963d20610ee622db3ee7;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index 8687f81410..a550d12777 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -41,6 +41,8 @@ class ChangePassword extends Maintenance { } 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 ) {