feature #15953 [TwigBridge] is_granted no longer raise an exception if the token storage is empty (lyrixx)
This PR was merged into the 2.8 branch.
Discussion
----------
[TwigBridge] is_granted no longer raise an exception if the token storage is empty
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #10159
| License | MIT
| Doc PR |
Commits
-------
6be68fd
[TwigBridge] is_granted no longer raise an exception if the token storage is empty
This commit is contained in:
commit
3bea01bd0d
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user