public function UserRouteEventSubscriber::onException in Username Enumeration Prevention 8
File
- src/
UserRouteEventSubscriber.php, line 63
Class
- UserRouteEventSubscriber
- Modifies user-related routes to respond with 404 rather than 403.
Namespace
Drupal\username_enumeration_preventionCode
public function onException(GetResponseForExceptionEvent $event) {
$routeMatch = RouteMatch::createFromRequest($event
->getRequest());
if ($event
->getException() instanceof AccessDeniedHttpException && in_array($routeMatch
->getRouteName(), $this
->getUserRoutes())) {
$event
->setException(new NotFoundHttpException());
}
}