From abb1eb7f10def414992ae7ca16aac23ed3baf114 Mon Sep 17 00:00:00 2001 From: Bas Strooband Date: Wed, 22 Jan 2020 15:28:07 +0100 Subject: [PATCH] Fix exception controller authentication exceptions Exceptions thrown while not logged in are wrapped in a HttpException. This is preventing the rendering of sane error message for the enduser. --- .../SelfServiceBundle/Controller/ExceptionController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php index 8593d1815..0cbc2abc5 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php @@ -21,6 +21,7 @@ use Exception; use Surfnet\StepupBundle\Controller\ExceptionController as BaseExceptionController; use Surfnet\StepupSelfService\SelfServiceBundle\Exception\MissingRequiredAttributeException; +use Symfony\Component\HttpKernel\Exception\HttpException; final class ExceptionController extends BaseExceptionController { @@ -32,9 +33,11 @@ protected function getPageTitleAndDescription(Exception $exception) { $translator = $this->getTranslator(); - if ($exception instanceof MissingRequiredAttributeException) { - $title = $translator->trans('stepup.error.missing_required_attribute.title'); - $description = $exception->getMessage(); + if ($exception instanceof HttpException) { + if ($exception instanceof MissingRequiredAttributeException) { + $title = $translator->trans('stepup.error.missing_required_attribute.title'); + $description = $exception->getMessage(); + } } if (isset($title) && isset($description)) {