summaryrefslogtreecommitdiffstats
path: root/Core/Validator/Constraint
diff options
context:
space:
mode:
authorHugo Hamon <hugo.hamon@sensio.com>2013-02-04 13:20:14 +0100
committerHugo Hamon <hugo.hamon@sensio.com>2013-02-04 13:20:14 +0100
commitc4fb5a816e5d46b52908a0ff1b84b4ce9d147cba (patch)
tree854f63714f1c4d59db5106af837d75a4700ab5f1 /Core/Validator/Constraint
parente642286ad42e113e0ed8e3343ad852121d2f467a (diff)
downloadsymfony-security-c4fb5a816e5d46b52908a0ff1b84b4ce9d147cba.zip
symfony-security-c4fb5a816e5d46b52908a0ff1b84b4ce9d147cba.tar.gz
symfony-security-c4fb5a816e5d46b52908a0ff1b84b4ce9d147cba.tar.bz2
[Security] renamed Constraint namespace to Constraints for validator classes in order to be consistent with the whole current validator API.
Diffstat (limited to 'Core/Validator/Constraint')
-rw-r--r--Core/Validator/Constraint/UserPassword.php15
-rw-r--r--Core/Validator/Constraint/UserPasswordValidator.php31
2 files changed, 15 insertions, 31 deletions
diff --git a/Core/Validator/Constraint/UserPassword.php b/Core/Validator/Constraint/UserPassword.php
index e90d9af..93ca24d 100644
--- a/Core/Validator/Constraint/UserPassword.php
+++ b/Core/Validator/Constraint/UserPassword.php
@@ -11,18 +11,19 @@
namespace Symfony\Component\Security\Core\Validator\Constraint;
-use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Security\Core\Validator\Constraints\UserPassword as BaseUserPassword;
/**
* @Annotation
+ *
+ * @deprecated Deprecated since version 2.2, to be removed in 2.3.
*/
-class UserPassword extends Constraint
+class UserPassword extends BaseUserPassword
{
- public $message = 'This value should be the user current password.';
- public $service = 'security.validator.user_password';
-
- public function validatedBy()
+ public function __construct($options = null)
{
- return $this->service;
+ trigger_error('UserPassword class in Symfony\Component\Security\Core\Validator\Constraint namespace is deprecated since version 2.2 and will be removed in 2.3. Use the Symfony\Component\Security\Core\Validator\Constraints\UserPassword class instead.', E_USER_DEPRECATED);
+
+ parent::__construct($options);
}
}
diff --git a/Core/Validator/Constraint/UserPasswordValidator.php b/Core/Validator/Constraint/UserPasswordValidator.php
index a54906b..0195fe5 100644
--- a/Core/Validator/Constraint/UserPasswordValidator.php
+++ b/Core/Validator/Constraint/UserPasswordValidator.php
@@ -11,36 +11,19 @@
namespace Symfony\Component\Security\Core\Validator\Constraint;
-use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
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\Security\Core\Validator\Constraints\UserPasswordValidator as BaseUserPasswordValidator;
-class UserPasswordValidator extends ConstraintValidator
+/**
+ * @deprecated Deprecated since version 2.2, to be removed in 2.3.
+ */
+class UserPasswordValidator extends BaseUserPasswordValidator
{
- private $securityContext;
- private $encoderFactory;
-
public function __construct(SecurityContextInterface $securityContext, EncoderFactoryInterface $encoderFactory)
{
- $this->securityContext = $securityContext;
- $this->encoderFactory = $encoderFactory;
- }
-
- public function validate($password, Constraint $constraint)
- {
- $user = $this->securityContext->getToken()->getUser();
-
- if (!$user instanceof UserInterface) {
- throw new ConstraintDefinitionException('The User must extend UserInterface');
- }
-
- $encoder = $this->encoderFactory->getEncoder($user);
+ trigger_error('UserPasswordValidator class in Symfony\Component\Security\Core\Validator\Constraint namespace is deprecated since version 2.2 and will be removed in 2.3. Use the Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator class instead.', E_USER_DEPRECATED);
- if (!$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
- $this->context->addViolation($constraint->message);
- }
+ parent::__construct($securityContext, $encoderFactory);
}
}