diff --git a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php index c945b81..2d832ce 100755 --- a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php @@ -133,25 +133,24 @@ public function buildForm(array $form, array &$form_state) { */ public function validateForm(array &$form, array &$form_state) { $flood_config = $this->configFactory->get('user.flood'); - if ($this->flood->isAllowed('user.password_request', $flood_config->get('ip_limit'), $flood_config->get('ip_window'))) { - $this->flood->register('user.password_request', $flood_config->get('ip_window')); - $name = trim($form_state['values']['name']); - // Try to load by email. - $users = $this->userStorageController->loadByProperties(array('mail' => $name, 'status' => '1')); - if (empty($users)) { - // No success, try to load by name. - $users = $this->userStorageController->loadByProperties(array('name' => $name, 'status' => '1')); - } - $account = reset($users); - if ($account && $account->id()) { - \Drupal::formBuilder()->setValue(array('#parents' => array('account')), $account, $form_state); - } - else { - $this->setFormError('name', $form_state, $this->t('Sorry, %name is not recognized as a username or an e-mail address.', array('%name' => $name))); - } + if (!$this->flood->isAllowed('user.password_request', $flood_config->get('ip_limit'), $flood_config->get('ip_window'))) { + $this->setFormError('name', $form_state, $this->t('Sorry, there were to many failed password recovery attempts for this account. Check your e-mail and use one of the password reset instructions from there.')); + return; + } + $this->flood->register('user.password_request', $flood_config->get('ip_window')); + $name = trim($form_state['values']['name']); + // Try to load by email. + $users = $this->userStorageController->loadByProperties(array('mail' => $name, 'status' => '1')); + if (empty($users)) { + // No success, try to load by name. + $users = $this->userStorageController->loadByProperties(array('name' => $name, 'status' => '1')); + } + $account = reset($users); + if ($account && $account->id()) { + \Drupal::formBuilder()->setValue(array('#parents' => array('account')), $account, $form_state); } else { - $this->setFormError('name', $form_state, $this->t('Sorry, there were to many failed password recovery attempts for this account. Check your e-mail and use one of the password reset instructions from there.')); + $this->setFormError('name', $form_state, $this->t('Sorry, %name is not recognized as a username or an e-mail address.', array('%name' => $name))); } }