if (!
isset($credentials['pass'
])) { throw new BadRequestHttpException('Missing credentials.pass.'
);
} $this->
floodControl($request,
$credentials['name'
]);
if ($this->
userIsBlocked($credentials['name'
])) { throw new BadRequestHttpException('The user has not been activated or is blocked.'
);
} if ($uid =
$this->userAuth->
authenticate($credentials['name'
],
$credentials['pass'
])) { $this->userFloodControl->
clear('user.http_login',
$this->
getLoginFloodIdentifier($request,
$credentials['name'
]));
/** @var \Drupal\user\UserInterface $user */
$user =
$this->userStorage->
load($uid);
$this->
userLoginFinalize($user);
// Send basic metadata about the logged in user.
$response_data =
[];
if ($user->
get('uid'
)->
access('view',
$user)) { $response_data['current_user'
]['uid'
] =
$user->
id();
} if ($user->
get('roles'
)->
access('view',
$user)) { $response_data['current_user'
]['roles'
] =
$user->
getRoles();
}