else { // Use $form_state->getUserInput() in the error message to guarantee
// that we send exactly what the user typed in. The value from
// $form_state->getValue() may have been modified by validation
// handlers that ran earlier than this one.
$user_input =
$form_state->
getUserInput();
$query =
isset($user_input['name'
]) ?
['name' =>
$user_input['name'
]] :
[];
$form_state->
setErrorByName('name',
$this->
t('Unrecognized username or password. <a href=":password">Forgot your password?</a>',
[':password' => Url::
fromRoute('user.pass',
[],
['query' =>
$query])->
toString()]));
$accounts =
$this->userStorage->
loadByProperties(['name' =>
$form_state->
getValue('name'
)]);
if (!
empty($accounts)) { $this->
logger('user'
)->
notice('Login attempt failed for %user.',
['%user' =>
$form_state->
getValue('name'
)]);
} else { // If the username entered is not a valid user,
// only store the IP address.
$this->
logger('user'
)->
notice('Login attempt failed from %ip.',
['%ip' =>
$this->
getRequest()->
getClientIp()]);
} } } elseif ($flood_control_user_identifier =
$form_state->
get('flood_control_user_identifier'
)) { // Clear past failures for this user so as not to block a user who might
// log in and out more than once in an hour.