You are here

function login_security_soft_block_validate in Login Security 8

Same name and namespace in other branches
  1. 6 login_security.module \login_security_soft_block_validate()
  2. 7 login_security.module \login_security_soft_block_validate()
  3. 2.x login_security.module \login_security_soft_block_validate()

Temporarily deny validation to users with excess invalid login attempts.

@url http://drupal.org/node/493164

1 string reference to 'login_security_soft_block_validate'
login_security_form_alter in ./login_security.module
Implements hook_form_alter().

File

./login_security.module, line 118
Login Security module hooks.

Code

function login_security_soft_block_validate(array $form, FormStateInterface $form_state) {
  $config = \Drupal::config('login_security.settings');
  $variables = _login_security_get_variables_by_name($form_state
    ->getValue('name'));

  // Check for host login attempts: Soft.
  if ($variables['@soft_block_attempts'] >= 1) {
    if ($variables['@ip_current_count'] >= $variables['@soft_block_attempts']) {
      $form_state
        ->setErrorByName('submit', SafeMarkup::format($config
        ->get('host_soft_banned'), $variables));
    }
  }
}