Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit 68bbd53

Browse files
authored
Merge pull request #204 from crosello/feature/authorization_checker_if_not_trustedroles
Do not call authorization checker if no trusted roles
2 parents 9e21486 + e48e83d commit 68bbd53

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/Validator/Constraints/IsTrueValidator.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class IsTrueValidator extends ConstraintValidator
6060
*
6161
* @var array
6262
*/
63-
protected $trusted_roles;
63+
protected $trustedRoles;
6464

6565
/**
6666
* The reCAPTCHA verify server URL.
@@ -76,7 +76,7 @@ class IsTrueValidator extends ConstraintValidator
7676
* @param array $httpProxy
7777
* @param bool $verifyHost
7878
* @param AuthorizationCheckerInterface|null $authorizationChecker
79-
* @param array $trusted_roles
79+
* @param array $trustedRoles
8080
* @param string $apiHost
8181
*/
8282
public function __construct(
@@ -86,7 +86,7 @@ public function __construct(
8686
array $httpProxy,
8787
$verifyHost,
8888
AuthorizationCheckerInterface $authorizationChecker = null,
89-
array $trusted_roles = array(),
89+
array $trustedRoles = array(),
9090
$apiHost = 'www.google.com')
9191
{
9292
$this->enabled = $enabled;
@@ -95,7 +95,7 @@ public function __construct(
9595
$this->httpProxy = $httpProxy;
9696
$this->verifyHost = $verifyHost;
9797
$this->authorizationChecker = $authorizationChecker;
98-
$this->trusted_roles = $trusted_roles;
98+
$this->trustedRoles = $trustedRoles;
9999
$this->recaptchaVerifyServer = 'https://'.$apiHost;
100100
}
101101

@@ -110,7 +110,9 @@ public function validate($value, Constraint $constraint)
110110
}
111111

112112
// if we have an authorized role
113-
if ($this->authorizationChecker && $this->authorizationChecker->isGranted($this->trusted_roles)) {
113+
if ($this->authorizationChecker
114+
&& count($this->trustedRoles) > 0
115+
&& $this->authorizationChecker->isGranted($this->trustedRoles)) {
114116
return;
115117
}
116118

0 commit comments

Comments
 (0)