X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBotPasswords.php;h=dfdbb067c065aa722aebbf595cc344a3f491c394;hb=40ced7e89ca9cd6896cd37b4b35051ed5754eb44;hp=ed3cd5e7e9b8619efb59ffff6179f5401ee6b1b1;hpb=5335a84c9ef221d03f264834cf136d9dd11a749a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBotPasswords.php b/includes/specials/SpecialBotPasswords.php index ed3cd5e7e9..7b2d1bcbfd 100644 --- a/includes/specials/SpecialBotPasswords.php +++ b/includes/specials/SpecialBotPasswords.php @@ -107,6 +107,9 @@ class SpecialBotPasswords extends FormSpecialPage { 'type' => 'check', 'label-message' => 'botpasswords-label-resetpassword', ]; + if ( $this->botPassword->isInvalid() ) { + $fields['resetPassword']['default'] = true; + } } $lang = $this->getLanguage(); @@ -123,7 +126,7 @@ class SpecialBotPasswords extends FormSpecialPage { $showGrants ), 'default' => array_map( - function( $g ) { + function ( $g ) { return "grant-$g"; }, $this->botPassword->getGrants() @@ -131,14 +134,14 @@ class SpecialBotPasswords extends FormSpecialPage { 'tooltips' => array_combine( array_map( 'MWGrants::getGrantsLink', $showGrants ), array_map( - function( $rights ) use ( $lang ) { + function ( $rights ) use ( $lang ) { return $lang->semicolonList( array_map( 'User::getRightDescription', $rights ) ); }, array_intersect_key( MWGrants::getRightsByGrant(), array_flip( $showGrants ) ) ) ), 'force-options-on' => array_map( - function( $g ) { + function ( $g ) { return "grant-$g"; }, MWGrants::getHiddenGrants() @@ -146,29 +149,46 @@ class SpecialBotPasswords extends FormSpecialPage { ]; $fields['restrictions'] = [ - 'class' => 'HTMLRestrictionsField', + 'class' => HTMLRestrictionsField::class, 'required' => true, 'default' => $this->botPassword->getRestrictions(), ]; } else { $linkRenderer = $this->getLinkRenderer(); + $passwordFactory = new PasswordFactory(); + $passwordFactory->init( $this->getConfig() ); + $dbr = BotPassword::getDB( DB_REPLICA ); $res = $dbr->select( 'bot_passwords', - [ 'bp_app_id' ], + [ 'bp_app_id', 'bp_password' ], [ 'bp_user' => $this->userId ], __METHOD__ ); foreach ( $res as $row ) { + try { + $password = $passwordFactory->newFromCiphertext( $row->bp_password ); + $passwordInvalid = $password instanceof InvalidPassword; + unset( $password ); + } catch ( PasswordError $ex ) { + $passwordInvalid = true; + } + + $text = $linkRenderer->makeKnownLink( + $this->getPageTitle( $row->bp_app_id ), + $row->bp_app_id + ); + if ( $passwordInvalid ) { + $text .= $this->msg( 'word-separator' )->escaped() + . $this->msg( 'botpasswords-label-needsreset' )->parse(); + } + $fields[] = [ 'section' => 'existing', 'type' => 'info', 'raw' => true, - 'default' => $linkRenderer->makeKnownLink( - $this->getPageTitle( $row->bp_app_id ), - $row->bp_app_id - ), + 'default' => $text, ]; } @@ -224,7 +244,7 @@ class SpecialBotPasswords extends FormSpecialPage { 'name' => 'op', 'value' => 'create', 'label-message' => 'botpasswords-label-create', - 'flags' => [ 'primary', 'constructive' ], + 'flags' => [ 'primary', 'progressive' ], ] ); }