*/
private $result;
+ /**
+ * @var string $method Identifies which password reset field was specified by the user.
+ */
+ private $method;
+
public function __construct() {
parent::__construct( 'PasswordReset', 'editmyprivateinfo' );
}
+ public function doesWrites() {
+ return true;
+ }
+
public function userCanExecute( User $user ) {
return $this->canChangePassword( $user ) === true && parent::userCanExecute( $user );
}
throw new ErrorPageError( 'internalerror', 'resetpass_forbidden' );
}
- return parent::checkExecutePermissions( $user );
+ parent::checkExecutePermissions( $user );
}
protected function getFormFields() {
* @return bool|array
*/
public function onSubmit( array $data ) {
- global $wgAuth;
+ global $wgAuth, $wgMinimalPasswordLength;
if ( isset( $data['Domain'] ) ) {
if ( $wgAuth->validDomain( $data['Domain'] ) ) {
return array( $error );
}
+ $this->method = $method;
+
if ( count( $users ) == 0 ) {
if ( $method == 'email' ) {
// Don't reveal whether or not an email address is in use
$passwords = array();
foreach ( $users as $user ) {
- $password = $user->randomPassword();
+ $password = PasswordFactory::generateRandomPasswordString( $wgMinimalPasswordLength );
$user->setNewpassword( $password );
$user->saveSettings();
$passwords[] = $this->msg( 'passwordreset-emailelement', $user->getName(), $password )
$this->getOutput()->addHTML( Html::rawElement( 'pre', array(), $this->email->escaped() ) );
}
- $this->getOutput()->addWikiMsg( 'passwordreset-emailsent' );
+ if ( $this->method === 'email' ) {
+ $this->getOutput()->addWikiMsg( 'passwordreset-emailsentemail' );
+ } else {
+ $this->getOutput()->addWikiMsg( 'passwordreset-emailsentusername' );
+ }
+
$this->getOutput()->returnToMain();
}