X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPasswordReset.php;h=a4f16bd7c97649cd6eb19d75b37f1ae28eaf2dbc;hb=c253b03fe5799331d34f390d426bd58d20fc50d6;hp=9746ef6983126055da72a9ce045ba083b981c095;hpb=aff17edd95620bff595dfa88013b422b38b1db2a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialPasswordReset.php b/includes/specials/SpecialPasswordReset.php index 9746ef6983..a4f16bd7c9 100644 --- a/includes/specials/SpecialPasswordReset.php +++ b/includes/specials/SpecialPasswordReset.php @@ -34,7 +34,7 @@ use MediaWiki\Auth\AuthManager; */ class SpecialPasswordReset extends FormSpecialPage { /** @var PasswordReset */ - private $passwordReset; + private $passwordReset = null; /** * @var string[] Temporary storage for the passwords which have been sent out, keyed by username. @@ -53,7 +53,13 @@ class SpecialPasswordReset extends FormSpecialPage { public function __construct() { parent::__construct( 'PasswordReset', 'editmyprivateinfo' ); - $this->passwordReset = new PasswordReset( $this->getConfig(), AuthManager::singleton() ); + } + + private function getPasswordReset() { + if ( $this->passwordReset === null ) { + $this->passwordReset = new PasswordReset( $this->getConfig(), AuthManager::singleton() ); + } + return $this->passwordReset; } public function doesWrites() { @@ -61,11 +67,11 @@ class SpecialPasswordReset extends FormSpecialPage { } public function userCanExecute( User $user ) { - return $this->passwordReset->isAllowed( $user )->isGood(); + return $this->getPasswordReset()->isAllowed( $user )->isGood(); } public function checkExecutePermissions( User $user ) { - $status = Status::wrap( $this->passwordReset->isAllowed( $user ) ); + $status = Status::wrap( $this->getPasswordReset()->isAllowed( $user ) ); if ( !$status->isGood() ) { throw new ErrorPageError( 'internalerror', $status->getMessage() ); } @@ -94,14 +100,6 @@ class SpecialPasswordReset extends FormSpecialPage { ]; } - if ( $this->getUser()->isAllowed( 'passwordreset' ) ) { - $a['Capture'] = [ - 'type' => 'check', - 'label-message' => 'passwordreset-capture', - 'help-message' => 'passwordreset-capture-help', - ]; - } - return $a; } @@ -138,22 +136,12 @@ class SpecialPasswordReset extends FormSpecialPage { * @return Status */ public function onSubmit( array $data ) { - if ( isset( $data['Capture'] ) && !$this->getUser()->isAllowed( 'passwordreset' ) ) { - // The user knows they don't have the passwordreset permission, - // but they tried to spoof the form. That's naughty - throw new PermissionsError( 'passwordreset' ); - } - $username = isset( $data['Username'] ) ? $data['Username'] : null; $email = isset( $data['Email'] ) ? $data['Email'] : null; - $capture = !empty( $data['Capture'] ); $this->method = $username ? 'username' : 'email'; $this->result = Status::wrap( - $this->passwordReset->execute( $this->getUser(), $username, $email, $capture ) ); - if ( $capture && $this->result->isOK() ) { - $this->passwords = $this->result->getValue(); - } + $this->getPasswordReset()->execute( $this->getUser(), $username, $email ) ); if ( $this->result->hasMessage( 'actionthrottledtext' ) ) { throw new ThrottledError; @@ -163,28 +151,6 @@ class SpecialPasswordReset extends FormSpecialPage { } public function onSuccess() { - if ( $this->getUser()->isAllowed( 'passwordreset' ) && $this->passwords ) { - // @todo Logging - - if ( $this->result->isGood() ) { - $this->getOutput()->addWikiMsg( 'passwordreset-emailsent-capture2', - count( $this->passwords ) ); - } else { - $this->getOutput()->addWikiMsg( 'passwordreset-emailerror-capture2', - $this->result->getMessage(), key( $this->passwords ), count( $this->passwords ) ); - } - - $this->getOutput()->addHTML( Html::openElement( 'ul' ) ); - foreach ( $this->passwords as $username => $pwd ) { - $this->getOutput()->addHTML( Html::rawElement( 'li', [], - htmlspecialchars( $username, ENT_QUOTES ) - . $this->msg( 'colon-separator' )->text() - . htmlspecialchars( $pwd, ENT_QUOTES ) - ) ); - } - $this->getOutput()->addHTML( Html::closeElement( 'ul' ) ); - } - if ( $this->method === 'email' ) { $this->getOutput()->addWikiMsg( 'passwordreset-emailsentemail' ); } else { @@ -199,7 +165,7 @@ class SpecialPasswordReset extends FormSpecialPage { * @return bool */ public function isListed() { - if ( $this->passwordReset->isAllowed( $this->getUser() )->isGood() ) { + if ( $this->getPasswordReset()->isAllowed( $this->getUser() )->isGood() ) { return parent::isListed(); }