Skip to content

Commit b4ef9b0

Browse files
authored
Merge pull request #2584 from craue/1.3.x-fix-issue-2580
[1.3] added NotBlank validation constraint to forbid blank current user's password
2 parents fe6ee1c + a3dcdff commit b4ef9b0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Form/Type/ChangePasswordFormType.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Form\AbstractType;
1717
use Symfony\Component\Security\Core\Validator\Constraint\UserPassword as OldUserPassword;
1818
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
19+
use Symfony\Component\Validator\Constraints\NotBlank;
1920

2021
class ChangePasswordFormType extends AbstractType
2122
{
@@ -32,7 +33,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
3233
'label' => 'form.current_password',
3334
'translation_domain' => 'FOSUserBundle',
3435
'mapped' => false,
35-
'constraints' => $constraint,
36+
'constraints' => array(
37+
new NotBlank(),
38+
$constraint,
39+
),
3640
));
3741
$builder->add('new', 'repeated', array(
3842
'type' => 'password',

Form/Type/ProfileFormType.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
1717
use Symfony\Component\Security\Core\Validator\Constraint\UserPassword as OldUserPassword;
1818
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
19+
use Symfony\Component\Validator\Constraints\NotBlank;
1920

2021
class ProfileFormType extends AbstractType
2122
{
@@ -44,7 +45,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4445
'label' => 'form.current_password',
4546
'translation_domain' => 'FOSUserBundle',
4647
'mapped' => false,
47-
'constraints' => $constraint,
48+
'constraints' => array(
49+
new NotBlank(),
50+
$constraint,
51+
),
4852
));
4953
}
5054

0 commit comments

Comments
 (0)