Skip to content

Commit 7a6c7d9

Browse files
authored
Validates empty current password
Relates to: symfony/symfony#23341 symfony/security-core@3bc0bcf I can change user password without typing my current password.
1 parent a1b3867 commit 7a6c7d9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Form/Type/ChangePasswordFormType.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Form\AbstractType;
1616
use Symfony\Component\Form\FormBuilderInterface;
1717
use Symfony\Component\OptionsResolver\OptionsResolver;
18+
use Symfony\Component\Validator\Constraints\NotNull;
1819
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
1920

2021
class ChangePasswordFormType extends AbstractType
@@ -49,7 +50,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4950
'label' => 'form.current_password',
5051
'translation_domain' => 'FOSUserBundle',
5152
'mapped' => false,
52-
'constraints' => new UserPassword($constraintsOptions),
53+
'constraints' => [
54+
new NotNull(),
55+
new UserPassword($constraintsOptions),
56+
]
5357
));
5458

5559
$builder->add('plainPassword', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\RepeatedType'), array(

0 commit comments

Comments
 (0)