aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-11-07 00:17:37 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-11-07 00:17:37 +0100
commit18f8f32f70a3f76b307f4255eee0f51187b07283 (patch)
tree0d81173a7e58dfff2e018327a60391e77292dfa8 /src/Wallabag
parent5ead137fe6885395ffcc99903263dec235f2c051 (diff)
downloadwallabag-18f8f32f70a3f76b307f4255eee0f51187b07283.tar.gz
wallabag-18f8f32f70a3f76b307f4255eee0f51187b07283.tar.zst
wallabag-18f8f32f70a3f76b307f4255eee0f51187b07283.zip
Fix security.context deprecation
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php4
-rw-r--r--src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php6
-rw-r--r--src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php12
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml2
4 files changed, 12 insertions, 12 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 1fee56ad..74bfe4dc 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -40,7 +40,7 @@ class WallabagRestController extends FOSRestController
40 40
41 private function validateAuthentication() 41 private function validateAuthentication()
42 { 42 {
43 if (false === $this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) { 43 if (false === $this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
44 throw new AccessDeniedException(); 44 throw new AccessDeniedException();
45 } 45 }
46 } 46 }
@@ -347,7 +347,7 @@ class WallabagRestController extends FOSRestController
347 */ 347 */
348 private function validateUserAccess($requestUserId) 348 private function validateUserAccess($requestUserId)
349 { 349 {
350 $user = $this->get('security.context')->getToken()->getUser(); 350 $user = $this->get('security.token_storage')->getToken()->getUser();
351 if ($requestUserId != $user->getId()) { 351 if ($requestUserId != $user->getId()) {
352 throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId()); 352 throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId());
353 } 353 }
diff --git a/src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php b/src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php
index 119889b3..09cde0f6 100644
--- a/src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php
+++ b/src/Wallabag/ApiBundle/Tests/AbstractControllerTest.php
@@ -25,7 +25,6 @@ abstract class AbstractControllerTest extends WebTestCase
25 $client = static::createClient(); 25 $client = static::createClient();
26 $container = $client->getContainer(); 26 $container = $client->getContainer();
27 27
28 $session = $container->get('session');
29 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ 28 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
30 $userManager = $container->get('fos_user.user_manager'); 29 $userManager = $container->get('fos_user.user_manager');
31 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */ 30 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
@@ -36,9 +35,10 @@ abstract class AbstractControllerTest extends WebTestCase
36 $loginManager->loginUser($firewallName, $user); 35 $loginManager->loginUser($firewallName, $user);
37 36
38 // save the login token into the session and put it in a cookie 37 // save the login token into the session and put it in a cookie
39 $container->get('session')->set('_security_'.$firewallName, 38 $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
40 serialize($container->get('security.context')->getToken()));
41 $container->get('session')->save(); 39 $container->get('session')->save();
40
41 $session = $container->get('session');
42 $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId())); 42 $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
43 43
44 return $client; 44 return $client;
diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
index 054a3752..489f39d1 100644
--- a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
+++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
@@ -3,7 +3,7 @@
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Liip\ThemeBundle\Helper\DeviceDetectionInterface; 5use Liip\ThemeBundle\Helper\DeviceDetectionInterface;
6use Symfony\Component\Security\Core\SecurityContextInterface; 6use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
7use Wallabag\UserBundle\Entity\User; 7use Wallabag\UserBundle\Entity\User;
8 8
9/** 9/**
@@ -14,16 +14,16 @@ use Wallabag\UserBundle\Entity\User;
14 */ 14 */
15class DetectActiveTheme implements DeviceDetectionInterface 15class DetectActiveTheme implements DeviceDetectionInterface
16{ 16{
17 protected $securityContext; 17 protected $tokenStorage;
18 protected $defaultTheme; 18 protected $defaultTheme;
19 19
20 /** 20 /**
21 * @param SecurityContextInterface $securityContext Needed to retrieve the current user 21 * @param TokenStorageInterface $tokenStorage Needed to retrieve the current user
22 * @param string $defaultTheme Default theme when user isn't logged in 22 * @param string $defaultTheme Default theme when user isn't logged in
23 */ 23 */
24 public function __construct(SecurityContextInterface $securityContext, $defaultTheme) 24 public function __construct(TokenStorageInterface $tokenStorage, $defaultTheme)
25 { 25 {
26 $this->securityContext = $securityContext; 26 $this->tokenStorage = $tokenStorage;
27 $this->defaultTheme = $defaultTheme; 27 $this->defaultTheme = $defaultTheme;
28 } 28 }
29 29
@@ -42,7 +42,7 @@ class DetectActiveTheme implements DeviceDetectionInterface
42 */ 42 */
43 public function getType() 43 public function getType()
44 { 44 {
45 $token = $this->securityContext->getToken(); 45 $token = $this->tokenStorage->getToken();
46 46
47 if (is_null($token)) { 47 if (is_null($token)) {
48 return $this->defaultTheme; 48 return $this->defaultTheme;
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index 3c479ff6..debbf39e 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -2,7 +2,7 @@ services:
2 wallabag_core.helper.detect_active_theme: 2 wallabag_core.helper.detect_active_theme:
3 class: Wallabag\CoreBundle\Helper\DetectActiveTheme 3 class: Wallabag\CoreBundle\Helper\DetectActiveTheme
4 arguments: 4 arguments:
5 - @security.context 5 - @security.token_storage
6 - %theme% # default theme from parameters.yml 6 - %theme% # default theme from parameters.yml
7 7
8 # custom form type 8 # custom form type