diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 0dadb33..d2bf263 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -38,6 +38,9 @@ class UserController extends AbstractController if ($this->isGranted('ROLE_SUDALYS_ADMIN')) { $userId = $request->attributes->get('id'); $user = $entityManager->getRepository(User::class)->find($userId); + if(!$user) { + throw $this->createNotFoundException('User not found'); + } $userOrganizations = $this->userOrganizationService->getUserOrganizations($user); } return $this->render('user/profile.html.twig', [ diff --git a/templates/bundles/TwigBundle/Exception/error404.html.twig b/templates/bundles/TwigBundle/Exception/error404.html.twig new file mode 100644 index 0000000..7597d0e --- /dev/null +++ b/templates/bundles/TwigBundle/Exception/error404.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}Page Not Found (404){% endblock %} + +{% block body %} +
+{% endblock %} \ No newline at end of file