diff options
author | Bernhard Schussek <bschussek@gmail.com> | 2014-03-10 12:51:04 +0000 |
---|---|---|
committer | Bernhard Schussek <bschussek@gmail.com> | 2014-03-10 12:58:20 +0000 |
commit | ef0a43829bba00b8e030331ed1ec414ff49fcbc9 (patch) | |
tree | 14ad08a0ba48a08fdf14529f961ba75c25e83a42 | |
parent | c5626a4f8a9d6830fc08b6d24f372a2328ca7b46 (diff) | |
download | symfony-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.php | 5 |
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) { |