2015-02-17 20:03:23 +00:00
|
|
|
<?php
|
2015-05-30 11:52:26 +00:00
|
|
|
|
2024-02-19 00:30:12 +00:00
|
|
|
namespace Wallabag\Form\Type;
|
2015-02-17 20:03:23 +00:00
|
|
|
|
|
|
|
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;
|
2022-08-28 14:59:43 +00:00
|
|
|
use Symfony\Component\Validator\Constraints\Length;
|
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
2015-02-17 20:03:23 +00:00
|
|
|
|
|
|
|
class ChangePasswordType extends AbstractType
|
|
|
|
{
|
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
|
|
{
|
|
|
|
$builder
|
2016-04-12 09:36:01 +00:00
|
|
|
->add('old_password', PasswordType::class, [
|
|
|
|
'constraints' => new UserPassword(['message' => 'validator.password_wrong_value']),
|
2016-03-09 07:59:08 +00:00
|
|
|
'label' => 'config.form_password.old_password_label',
|
2016-04-12 09:36:01 +00:00
|
|
|
])
|
|
|
|
->add('new_password', RepeatedType::class, [
|
2015-12-22 12:00:37 +00:00
|
|
|
'type' => PasswordType::class,
|
2016-03-09 07:59:08 +00:00
|
|
|
'invalid_message' => 'validator.password_must_match',
|
2015-02-17 20:03:23 +00:00
|
|
|
'required' => true,
|
2016-04-12 09:36:01 +00:00
|
|
|
'first_options' => ['label' => 'config.form_password.new_password_label'],
|
|
|
|
'second_options' => ['label' => 'config.form_password.repeat_new_password_label'],
|
|
|
|
'constraints' => [
|
2022-08-28 14:59:43 +00:00
|
|
|
new Length([
|
2015-02-17 21:45:20 +00:00
|
|
|
'min' => 8,
|
2016-03-09 07:59:08 +00:00
|
|
|
'minMessage' => 'validator.password_too_short',
|
2016-04-12 09:36:01 +00:00
|
|
|
]),
|
2022-08-28 14:59:43 +00:00
|
|
|
new NotBlank(),
|
2016-04-12 09:36:01 +00:00
|
|
|
],
|
2016-03-09 07:59:08 +00:00
|
|
|
'label' => 'config.form_password.new_password_label',
|
2016-04-12 09:36:01 +00:00
|
|
|
])
|
|
|
|
->add('save', SubmitType::class, [
|
2016-03-09 07:59:08 +00:00
|
|
|
'label' => 'config.form.save',
|
2016-04-12 09:36:01 +00:00
|
|
|
])
|
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';
|
|
|
|
}
|
|
|
|
}
|