X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=maintenance%2FcreateAndPromote.php;h=3591b9ce2456f0728c3c058571e88120c2b327d3;hb=52fc0648f87e5b8b917a7780030a3eec02f16a43;hp=9abc297dc3f8cd656fb3cea9c8a6675ae748cacd;hpb=601519ee36462faabacf4547c9aefaf7e8726476;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 9abc297dc3..3591b9ce24 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -56,6 +56,8 @@ class CreateAndPromote extends Maintenance { } public function execute() { + global $wgDisableAuthManager; + $username = $this->getArg( 0 ); $password = $this->getArg( 1 ); $force = $this->hasOption( 'force' ); @@ -79,11 +81,16 @@ class CreateAndPromote extends Maintenance { $groups = array_filter( self::$permitRoles, [ $this, 'hasOption' ] ); if ( $this->hasOption( 'custom-groups' ) ) { + $allGroups = array_flip( User::getAllGroups() ); $customGroupsText = $this->getOption( 'custom-groups' ); if ( $customGroupsText !== '' ) { $customGroups = explode( ',', $customGroupsText ); foreach ( $customGroups as $customGroup ) { - $groups[] = trim( $customGroup ); + if ( isset( $allGroups[$customGroup] ) ) { + $groups[] = trim( $customGroup ); + } else { + $this->output( "$customGroup is not a valid group, ignoring!\n" ); + } } } } @@ -115,7 +122,18 @@ class CreateAndPromote extends Maintenance { if ( $password ) { # Try to set the password try { - $user->setPassword( $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' ) ); + } + } if ( $exists ) { $this->output( "Password set.\n" ); $user->saveSettings();