diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 60dc389cd..8faf23a02 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -236,7 +236,7 @@ class Customer extends BaseAction implements EventSubscriberInterface { $successUrl = $form->getSuccessUrl(); - if ($this->securityContext->getContext() === SecurityContext::CONTEXT_FRONT_OFFICE) { + if ($this->getSecurityContext(SecurityContext::CONTEXT_BACK_OFFICE)->getUser() === null) { $this->processSuccessfullFrontEndLogin($event, $user, $form, $sendLoginEvent); } else { $successUrl = str_replace("__ID__", $user->getId(), $successUrl); @@ -252,7 +252,7 @@ class Customer extends BaseAction implements EventSubscriberInterface // Success -> store user in security context $this->getFrontSecurityContext()->setUser($user); - if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event); + if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event); } diff --git a/core/lib/Thelia/Admin/Controller/BaseAdminController.php b/core/lib/Thelia/Admin/Controller/BaseAdminController.php index 827c53618..84ccd7bd9 100755 --- a/core/lib/Thelia/Admin/Controller/BaseAdminController.php +++ b/core/lib/Thelia/Admin/Controller/BaseAdminController.php @@ -23,9 +23,9 @@ namespace Thelia\Admin\Controller; use Symfony\Component\Routing\RequestContext; -use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpFoundation\Response; +use Thelia\Core\DependencyInjection\ContainerAware; use Thelia\Form\BaseForm; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\HttpKernelInterface; diff --git a/core/lib/Thelia/Core/Controller/ControllerResolver.php b/core/lib/Thelia/Core/Controller/ControllerResolver.php index ac7fb37c4..ebf0eff86 100755 --- a/core/lib/Thelia/Core/Controller/ControllerResolver.php +++ b/core/lib/Thelia/Core/Controller/ControllerResolver.php @@ -1,4 +1,25 @@ . */ +/* */ +/*************************************************************************************/ namespace Thelia\Core\Controller; diff --git a/core/lib/Thelia/Core/DependencyInjection/ContainerAware.php b/core/lib/Thelia/Core/DependencyInjection/ContainerAware.php new file mode 100644 index 000000000..42dd46e7e --- /dev/null +++ b/core/lib/Thelia/Core/DependencyInjection/ContainerAware.php @@ -0,0 +1,53 @@ +. */ +/* */ +/*************************************************************************************/ + + +namespace Thelia\Core\DependencyInjection; + + +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Core\Security\SecurityContext; + +class ContainerAware implements ContainerAwareInterface { + + /** + * @var ContainerInterface + * + * @api + */ + protected $container; + + /** + * Sets the Container. + * + * @param ContainerInterface|null $container A ContainerInterface instance or null + * + * @api + */ + public function setContainer(ContainerInterface $container = null) + { + $container->get('request')->setContext(SecurityContext::CONTEXT_BACK_OFFICE); + $this->container = $container; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/HttpFoundation/Request.php b/core/lib/Thelia/Core/HttpFoundation/Request.php index 573cfe228..f3711a7dd 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Request.php +++ b/core/lib/Thelia/Core/HttpFoundation/Request.php @@ -23,9 +23,13 @@ namespace Thelia\Core\HttpFoundation; use Symfony\Component\HttpFoundation\Request as BaseRequest; +use Thelia\Core\Security\SecurityContext; -class Request extends BaseRequest{ +class Request extends BaseRequest +{ + + protected $context = SecurityContext::CONTEXT_FRONT_OFFICE; public function getProductId() { @@ -48,4 +52,14 @@ class Request extends BaseRequest{ return $uri . $additionalQs; } + public function setContext($context) + { + $this->context = $context; + } + + public function getContext() + { + return $this->context; + } + } \ No newline at end of file