mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
fix errors when creating user and updating password
This commit is contained in:
@@ -6,6 +6,11 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Regex;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
|
||||
use Chill\MainBundle\Form\UserPasswordType;
|
||||
|
||||
@@ -22,8 +27,31 @@ class UserType extends AbstractType
|
||||
->add('email')
|
||||
;
|
||||
if ($options['is_creation']) {
|
||||
$builder->add('plainPassword', UserPasswordType::class, array(
|
||||
'mapped' => false
|
||||
$builder->add('plainPassword', RepeatedType::class, array(
|
||||
'mapped' => false,
|
||||
'type' => PasswordType::class,
|
||||
'required' => false,
|
||||
'options' => array(),
|
||||
'first_options' => array(
|
||||
'label' => 'Password'
|
||||
),
|
||||
'second_options' => array(
|
||||
'label' => 'Repeat the password'
|
||||
),
|
||||
'invalid_message' => "The password fields must match",
|
||||
'constraints' => array(
|
||||
new Length(array(
|
||||
'min' => 9,
|
||||
'minMessage' => 'The password must be greater than {{ limit }} characters'
|
||||
)),
|
||||
new NotBlank(),
|
||||
new Regex(array(
|
||||
'pattern' => "/((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\/{}~=µ\(\)£]).{6,})/",
|
||||
'message' => "The password must contains one letter, one "
|
||||
. "capitalized letter, one number and one special character "
|
||||
. "as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed."
|
||||
))
|
||||
)
|
||||
));
|
||||
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user