Skip to content

Commit

Permalink
Fix the BlameListener
Browse files Browse the repository at this point in the history
The update to new Security APIs was applied only partially in this
listener.
  • Loading branch information
stof committed Aug 12, 2015
1 parent 5ab4c86 commit 7b31445
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.1 (2015-08-12)

* Fixed the BlameListener

## 1.2.0 (2015-08-12)

Bugfixes:
Expand Down
17 changes: 10 additions & 7 deletions EventListener/BlameListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
Expand All @@ -18,10 +19,8 @@
*/
class BlameListener implements EventSubscriberInterface
{
/**
* @var SecurityContextInterface
*/
private $securityContext;
private $authorizationChecker;
private $tokenStorage;

/**
* @var BlameableListener
Expand Down Expand Up @@ -54,12 +53,16 @@ public function __construct(BlameableListener $blameableListener, $tokenStorage
*/
public function onKernelRequest(GetResponseEvent $event)
{
if (null === $this->securityContext) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}

if (null === $this->tokenStorage || null === $this->authorizationChecker) {
return;
}

$token = $this->securityContext->getToken();
if (null !== $token && $this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$token = $this->tokenStorage->getToken();
if (null !== $token && $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$this->blameableListener->setUserValue($token->getUser());
}
}
Expand Down

0 comments on commit 7b31445

Please sign in to comment.