From 3445ec9ef285020a467f6e26e865d1d3ac58583d Mon Sep 17 00:00:00 2001 From: talha-core <124266517+talha-core@users.noreply.github.com> Date: Thu, 20 Jul 2023 12:41:51 +0500 Subject: [PATCH 1/4] Update access_denied_handler.rst --- security/access_denied_handler.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/security/access_denied_handler.rst b/security/access_denied_handler.rst index 5671b0538a1..0c811f00ea4 100644 --- a/security/access_denied_handler.rst +++ b/security/access_denied_handler.rst @@ -23,27 +23,28 @@ This interface has one method (``start()``) that is called whenever an unauthenticated user tries to access a protected resource:: // src/Security/AuthenticationEntryPoint.php - namespace App\Security; - use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; - + class AuthenticationEntryPoint implements AuthenticationEntryPointInterface { public function __construct( private UrlGeneratorInterface $urlGenerator, ) { } - + public function start(Request $request, AuthenticationException $authException = null): RedirectResponse { // add a custom flash message and redirect to the login page - $request->getSession()->getFlashBag()->add('note', 'You have to login in order to access this page.'); - - return new RedirectResponse($this->urlGenerator->generate('security_login')); + /** @var FlashBagInterface */ + $flashBag = $request->getSession()->getBag('flashes'); + $flashBag->add('note', 'You have to login in order to access this page.'); + + return new RedirectResponse($this->urlGenerator->generate('coregenionShop_loginMain')); } } From af15531f0260c9a527cfec151c25d07dc7e190ab Mon Sep 17 00:00:00 2001 From: talha-core <124266517+talha-core@users.noreply.github.com> Date: Thu, 20 Jul 2023 12:44:45 +0500 Subject: [PATCH 2/4] Update access_denied_handler.rst --- security/access_denied_handler.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/security/access_denied_handler.rst b/security/access_denied_handler.rst index 0c811f00ea4..89d8d0c2cf3 100644 --- a/security/access_denied_handler.rst +++ b/security/access_denied_handler.rst @@ -23,6 +23,8 @@ This interface has one method (``start()``) that is called whenever an unauthenticated user tries to access a protected resource:: // src/Security/AuthenticationEntryPoint.php + namespace App\Security; + use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; @@ -36,14 +38,14 @@ unauthenticated user tries to access a protected resource:: private UrlGeneratorInterface $urlGenerator, ) { } - + public function start(Request $request, AuthenticationException $authException = null): RedirectResponse { // add a custom flash message and redirect to the login page /** @var FlashBagInterface */ $flashBag = $request->getSession()->getBag('flashes'); $flashBag->add('note', 'You have to login in order to access this page.'); - + return new RedirectResponse($this->urlGenerator->generate('coregenionShop_loginMain')); } } From 1550564c4f01f610904cc3ef2b10c3800a6e661a Mon Sep 17 00:00:00 2001 From: talha-core <124266517+talha-core@users.noreply.github.com> Date: Thu, 20 Jul 2023 12:45:35 +0500 Subject: [PATCH 3/4] Update access_denied_handler.rst --- security/access_denied_handler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/access_denied_handler.rst b/security/access_denied_handler.rst index 89d8d0c2cf3..b7eef142911 100644 --- a/security/access_denied_handler.rst +++ b/security/access_denied_handler.rst @@ -46,7 +46,7 @@ unauthenticated user tries to access a protected resource:: $flashBag = $request->getSession()->getBag('flashes'); $flashBag->add('note', 'You have to login in order to access this page.'); - return new RedirectResponse($this->urlGenerator->generate('coregenionShop_loginMain')); + return new RedirectResponse($this->urlGenerator->generate('security_login')); } } From 7b344c02eb9a8af68b149eec0ea24a2a88556589 Mon Sep 17 00:00:00 2001 From: talha-core <124266517+talha-core@users.noreply.github.com> Date: Thu, 20 Jul 2023 12:49:23 +0500 Subject: [PATCH 4/4] Update access_denied_handler.rst --- security/access_denied_handler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/access_denied_handler.rst b/security/access_denied_handler.rst index b7eef142911..404c222e4c9 100644 --- a/security/access_denied_handler.rst +++ b/security/access_denied_handler.rst @@ -31,7 +31,7 @@ unauthenticated user tries to access a protected resource:: use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; - + class AuthenticationEntryPoint implements AuthenticationEntryPointInterface { public function __construct(