function UserFloodSubscriber::blockedUser

Same name in other branches
  1. 9 core/modules/user/src/EventSubscriber/UserFloodSubscriber.php \Drupal\user\EventSubscriber\UserFloodSubscriber::blockedUser()
  2. 10 core/modules/user/src/EventSubscriber/UserFloodSubscriber.php \Drupal\user\EventSubscriber\UserFloodSubscriber::blockedUser()

An attempt to login has been blocked based on user name.

Parameters

\Drupal\user\Event\UserFloodEvent $floodEvent: The flood event.

File

core/modules/user/src/EventSubscriber/UserFloodSubscriber.php, line 48

Class

UserFloodSubscriber
Logs details of User Flood Control events.

Namespace

Drupal\user\EventSubscriber

Code

public function blockedUser(UserFloodEvent $floodEvent) {
    if (Settings::get('log_user_flood', TRUE)) {
        $uid = $floodEvent->getUid();
        if ($floodEvent->hasIp()) {
            $ip = $floodEvent->getIp();
            $this->logger
                ->notice('Flood control blocked login attempt for uid %uid from %ip', [
                '%uid' => $uid,
                '%ip' => $ip,
            ]);
            return;
        }
        $this->logger
            ->notice('Flood control blocked login attempt for uid %uid', [
            '%uid' => $uid,
        ]);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.