public function AdvbanMiddleware::handle in Advanced ban 8
File
- src/
AdvbanMiddleware.php, line 44
Class
- AdvbanMiddleware
- Provides a HTTP middleware to implement IP based banning.
Namespace
Drupal\advbanCode
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
$ip = $request
->getClientIp();
$ban_result = $this->banIpManager
->isBanned($ip, [
'expiry_check' => TRUE,
'info_output' => TRUE,
]);
if ($ban_result['is_banned']) {
$ban_text = $this->banIpManager
->banText([
'ip' => $ip,
'expiry_date' => $ban_result['expiry_date'],
]);
return new Response($ban_text, 403);
}
return $this->httpKernel
->handle($request, $type, $catch);
}