2015-02-17 20:03:23 +00:00
|
|
|
<?php
|
2015-05-30 11:52:26 +00:00
|
|
|
|
2015-02-17 20:03:23 +00:00
|
|
|
namespace Wallabag\CoreBundle\Form\Type;
|
|
|
|
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
2015-12-22 09:16:34 +00:00
|
|
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
2015-02-17 20:03:23 +00:00
|
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
|
|
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
|
|
|
|
use Symfony\Component\Validator\Constraints;
|
|
|
|
|
|
|
|
class ChangePasswordType extends AbstractType
|
|
|
|
{
|
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
|
|
{
|
|
|
|
$builder
|
2015-12-22 09:16:34 +00:00
|
|
|
->add('old_password', PasswordType::class, array(
|
2015-02-17 20:03:23 +00:00
|
|
|
'constraints' => new UserPassword(array('message' => 'Wrong value for your current password')),
|
|
|
|
))
|
2015-12-22 09:16:34 +00:00
|
|
|
->add('new_password', RepeatedType::class, array(
|
2015-12-22 12:00:37 +00:00
|
|
|
'type' => PasswordType::class,
|
2015-02-17 20:03:23 +00:00
|
|
|
'invalid_message' => 'The password fields must match.',
|
|
|
|
'required' => true,
|
2015-08-20 05:53:55 +00:00
|
|
|
'first_options' => array('label' => 'New password'),
|
2015-02-17 20:03:23 +00:00
|
|
|
'second_options' => array('label' => 'Repeat new password'),
|
|
|
|
'constraints' => array(
|
|
|
|
new Constraints\Length(array(
|
2015-02-17 21:45:20 +00:00
|
|
|
'min' => 8,
|
2015-02-22 08:30:25 +00:00
|
|
|
'minMessage' => 'Password should by at least 8 chars long',
|
2015-02-17 20:03:23 +00:00
|
|
|
)),
|
2015-02-17 21:45:20 +00:00
|
|
|
new Constraints\NotBlank(),
|
|
|
|
),
|
2015-02-17 20:03:23 +00:00
|
|
|
))
|
2015-12-22 09:16:34 +00:00
|
|
|
->add('save', SubmitType::class)
|
2015-02-17 20:03:23 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2015-12-22 09:16:34 +00:00
|
|
|
public function getBlockPrefix()
|
2015-02-17 20:03:23 +00:00
|
|
|
{
|
|
|
|
return 'change_passwd';
|
|
|
|
}
|
|
|
|
}
|