From 08e7e3f2bfcd29ac979b5302691d771d5e01a924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 25 Jan 2024 23:41:43 +0100 Subject: [PATCH] Fixed phpstan issue --- src/Security/AuthenticationEntryPoint.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Security/AuthenticationEntryPoint.php b/src/Security/AuthenticationEntryPoint.php index 3d6782ee..f99d2118 100644 --- a/src/Security/AuthenticationEntryPoint.php +++ b/src/Security/AuthenticationEntryPoint.php @@ -27,6 +27,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; @@ -60,7 +61,9 @@ class AuthenticationEntryPoint implements AuthenticationEntryPointInterface //Otherwise we redirect to the login page //Add a nice flash message to make it clear what happened - $request->getSession()->getFlashBag()->add('error', t('login.flash.access_denied_please_login')); + if ($request->getSession() instanceof Session) { + $request->getSession()->getFlashBag()->add('error', t('login.flash.access_denied_please_login')); + } return new RedirectResponse($this->urlGenerator->generate('login')); }