diff --git a/core/modules/user/src/RegisterForm.php b/core/modules/user/src/RegisterForm.php index ccbf5a0..141bcfb 100644 --- a/core/modules/user/src/RegisterForm.php +++ b/core/modules/user/src/RegisterForm.php @@ -7,10 +7,7 @@ namespace Drupal\user; -use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; /** @@ -21,13 +18,6 @@ class RegisterForm extends AccountForm { /** * {@inheritdoc} */ - public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, QueryFactory $entity_query) { - parent::__construct($entity_manager, $language_manager, $entity_query); - } - - /** - * {@inheritdoc} - */ public function form(array $form, FormStateInterface $form_state) { $user = $this->currentUser(); /** @var \Drupal\user\UserInterface $account */ @@ -84,16 +74,13 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $admin = $form_state->getValue('administer_users'); if (!\Drupal::config('user.settings')->get('verify_mail') || $admin) { - $pass = $form_state->getValue('pass'); + $pass = $form_state->getValue(array('pass', 0, 'value')); } else { $pass = user_password(); } - // Remove unneeded values. - $form_state->cleanValues(); - - $form_state->setValue('pass', $pass); + $form_state->setValue(array('pass', 0, 'value'), $pass); $form_state->setValue('init', $form_state->getValue('mail')); parent::submitForm($form, $form_state); @@ -108,14 +95,12 @@ public function save(array $form, FormStateInterface $form_state) { $admin = $form_state->getValue('administer_users'); $notify = !$form_state->isValueEmpty('notify'); - // Save has no return value so this cannot be tested. - // Assume save has gone through correctly. $account->save(); $form_state->set('user', $account); $form_state->setValue('uid', $account->id()); - $this->logger('user')->notice('New user: %name %email.', array('%name' => $form_state->getValue(array('name', 0, 'value')), '%email' => '<' . $form_state->getValue('mail') . '>', 'type' => \Drupal::l($this->t('Edit'), 'entity.user.edit_form', array('user' => $account->id())))); + $this->logger('user')->notice('New user: %name %email.', array('%name' => $account->getUsername(), '%email' => '<' . $account->getEMail() . '>', 'type' => \Drupal::l($this->t('Edit'), 'entity.user.edit_form', array('user' => $account->id())))); // Add plain text password into user account to generate mail tokens. $account->password = $pass; diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php index f44746f..6cdad4b 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -138,13 +138,13 @@ function testRegistrationEmailDuplicates() { // Attempt to create a new account using an existing email address. $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->assertText(t('The email address @email is already registered.', array('@email' => $duplicate_user->getEmail())), 'Supplying an exact duplicate email address displays an error message'); + $this->assertText(t('The email address @email is already taken.', array('@email' => $duplicate_user->getEmail())), 'Supplying an exact duplicate email address displays an error message'); // Attempt to bypass duplicate email registration validation by adding spaces. $edit['mail[0][value]'] = ' ' . $duplicate_user->getEmail() . ' '; $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->assertText(t('The email address @email is already registered.', array('@email' => $duplicate_user->getEmail())), 'Supplying a duplicate email address with added whitespace displays an error message'); + $this->assertText(t('The email address @email is already taken.', array('@email' => $duplicate_user->getEmail())), 'Supplying a duplicate email address with added whitespace displays an error message'); } function testRegistrationDefaultValues() {