mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-09 00:15:27 +00:00
Fix security.context deprecation
This commit is contained in:
parent
5ead137fe6
commit
18f8f32f70
4 changed files with 12 additions and 12 deletions
|
@ -40,7 +40,7 @@ class WallabagRestController extends FOSRestController
|
|||
|
||||
private function validateAuthentication()
|
||||
{
|
||||
if (false === $this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
|
||||
if (false === $this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
|
||||
throw new AccessDeniedException();
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ class WallabagRestController extends FOSRestController
|
|||
*/
|
||||
private function validateUserAccess($requestUserId)
|
||||
{
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
$user = $this->get('security.token_storage')->getToken()->getUser();
|
||||
if ($requestUserId != $user->getId()) {
|
||||
throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ abstract class AbstractControllerTest extends WebTestCase
|
|||
$client = static::createClient();
|
||||
$container = $client->getContainer();
|
||||
|
||||
$session = $container->get('session');
|
||||
/** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
|
||||
$userManager = $container->get('fos_user.user_manager');
|
||||
/** @var $loginManager \FOS\UserBundle\Security\LoginManager */
|
||||
|
@ -36,9 +35,10 @@ abstract class AbstractControllerTest extends WebTestCase
|
|||
$loginManager->loginUser($firewallName, $user);
|
||||
|
||||
// save the login token into the session and put it in a cookie
|
||||
$container->get('session')->set('_security_'.$firewallName,
|
||||
serialize($container->get('security.context')->getToken()));
|
||||
$container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
|
||||
$container->get('session')->save();
|
||||
|
||||
$session = $container->get('session');
|
||||
$client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
|
||||
|
||||
return $client;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Wallabag\CoreBundle\Helper;
|
||||
|
||||
use Liip\ThemeBundle\Helper\DeviceDetectionInterface;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
|
@ -14,16 +14,16 @@ use Wallabag\UserBundle\Entity\User;
|
|||
*/
|
||||
class DetectActiveTheme implements DeviceDetectionInterface
|
||||
{
|
||||
protected $securityContext;
|
||||
protected $tokenStorage;
|
||||
protected $defaultTheme;
|
||||
|
||||
/**
|
||||
* @param SecurityContextInterface $securityContext Needed to retrieve the current user
|
||||
* @param TokenStorageInterface $tokenStorage Needed to retrieve the current user
|
||||
* @param string $defaultTheme Default theme when user isn't logged in
|
||||
*/
|
||||
public function __construct(SecurityContextInterface $securityContext, $defaultTheme)
|
||||
public function __construct(TokenStorageInterface $tokenStorage, $defaultTheme)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->defaultTheme = $defaultTheme;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class DetectActiveTheme implements DeviceDetectionInterface
|
|||
*/
|
||||
public function getType()
|
||||
{
|
||||
$token = $this->securityContext->getToken();
|
||||
$token = $this->tokenStorage->getToken();
|
||||
|
||||
if (is_null($token)) {
|
||||
return $this->defaultTheme;
|
||||
|
|
|
@ -2,7 +2,7 @@ services:
|
|||
wallabag_core.helper.detect_active_theme:
|
||||
class: Wallabag\CoreBundle\Helper\DetectActiveTheme
|
||||
arguments:
|
||||
- @security.context
|
||||
- @security.token_storage
|
||||
- %theme% # default theme from parameters.yml
|
||||
|
||||
# custom form type
|
||||
|
|
Loading…
Reference in a new issue