You are here

public function UserLoginForm::validateName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::validateName()

Sets an error if supplied username has been blocked.

File

core/modules/user/src/Form/UserLoginForm.php, line 154
Contains \Drupal\user\Form\UserLoginForm.

Class

UserLoginForm
Provides a user login form.

Namespace

Drupal\user\Form

Code

public function validateName(array &$form, FormStateInterface $form_state) {
  if (!$form_state
    ->isValueEmpty('name') && user_is_blocked($form_state
    ->getValue('name'))) {

    // Blocked in user administration.
    $form_state
      ->setErrorByName('name', $this
      ->t('The username %name has not been activated or is blocked.', array(
      '%name' => $form_state
        ->getValue('name'),
    )));
  }
}