summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schussek <bschussek@gmail.com>2014-03-10 12:51:04 +0000
committerBernhard Schussek <bschussek@gmail.com>2014-03-10 12:58:20 +0000
commitef0a43829bba00b8e030331ed1ec414ff49fcbc9 (patch)
tree14ad08a0ba48a08fdf14529f961ba75c25e83a42
parentc5626a4f8a9d6830fc08b6d24f372a2328ca7b46 (diff)
downloadsymfony-security-ef0a43829bba00b8e030331ed1ec414ff49fcbc9.zip
symfony-security-ef0a43829bba00b8e030331ed1ec414ff49fcbc9.tar.gz
symfony-security-ef0a43829bba00b8e030331ed1ec414ff49fcbc9.tar.bz2
[Validator] Checked the constraint class in constraint validators
-rw-r--r--Core/Validator/Constraints/UserPasswordValidator.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/Core/Validator/Constraints/UserPasswordValidator.php b/Core/Validator/Constraints/UserPasswordValidator.php
index ab455f3..5f9ad2a 100644
--- a/Core/Validator/Constraints/UserPasswordValidator.php
+++ b/Core/Validator/Constraints/UserPasswordValidator.php
@@ -17,6 +17,7 @@ use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
+use Symfony\Component\Validator\Exception\UnexpectedTypeException;
class UserPasswordValidator extends ConstraintValidator
{
@@ -34,6 +35,10 @@ class UserPasswordValidator extends ConstraintValidator
*/
public function validate($password, Constraint $constraint)
{
+ if (!$constraint instanceof UserPassword) {
+ throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UserPassword');
+ }
+
$user = $this->securityContext->getToken()->getUser();
if (!$user instanceof UserInterface) {