[TwigBridge] is_granted no longer raise an exception if the token storage is empty

This commit is contained in:
Grégoire Pineau 2015-09-28 09:38:38 +02:00
parent 156368fa43
commit 6be68fd845

View File

@ -13,6 +13,7 @@ namespace Symfony\Bridge\Twig\Extension;
use Symfony\Component\Security\Acl\Voter\FieldVote;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
/**
* SecurityExtension exposes security context features.
@ -38,7 +39,11 @@ class SecurityExtension extends \Twig_Extension
$object = new FieldVote($object, $field);
}
return $this->securityChecker->isGranted($role, $object);
try {
return $this->securityChecker->isGranted($role, $object);
} catch (AuthenticationCredentialsNotFoundException $e) {
return false;
}
}
/**