[ ['handleRedirect', 200], ], ]; } public function handleRedirect(ExceptionEvent $event) { $exception = $event->getThrowable(); $redirectSet = false; if ($exception instanceof AccessDeniedHttpException || $exception instanceof AccessDeniedException) { if ($exception->getMessage() == 'User is not in a two-factor authentication process.') { $redirectSet = true; $event->setResponse(new RedirectResponse(path('home'))); } $email = 'none'; if ($user = $this->userContext->getActive()) { $email = $user->email; } $this->logger->notice("[TwoFactorBundle] Handle exception, user: {$email}", [ 'exception' => $exception->getMessage(), 'exception_class' => get_class($exception), 'redirect_set' => $redirectSet, ]); } } }