aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Form/Type
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Form/Type')
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php54
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/NewUserType.php5
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php35
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/UserInformationType.php2
4 files changed, 4 insertions, 92 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php
deleted file mode 100644
index 9e95eb47..00000000
--- a/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php
+++ /dev/null
@@ -1,54 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\Validator\Constraints;
8use Symfony\Component\Validator\ExecutionContextInterface;
9use Doctrine\Bundle\DoctrineBundle\Registry;
10
11class ForgotPasswordType extends AbstractType
12{
13 private $doctrine = null;
14
15 public function __construct(Registry $doctrine)
16 {
17 $this->doctrine = $doctrine;
18 }
19
20 public function buildForm(FormBuilderInterface $builder, array $options)
21 {
22 $builder
23 ->add('email', 'email', array(
24 'required' => true,
25 'constraints' => array(
26 new Constraints\Email(),
27 new Constraints\NotBlank(),
28 new Constraints\Callback(array(array($this, 'validateEmail'))),
29 ),
30 ))
31 ;
32 }
33
34 public function getName()
35 {
36 return 'forgot_password';
37 }
38
39 public function validateEmail($email, ExecutionContextInterface $context)
40 {
41 $user = $this->doctrine
42 ->getRepository('WallabagCoreBundle:User')
43 ->findOneByEmail($email);
44
45 if (!$user) {
46 $context->addViolationAt(
47 'email',
48 'No user found with this email',
49 array(),
50 $email
51 );
52 }
53 }
54}
diff --git a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
index 985cb55b..8aabc8bb 100644
--- a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
@@ -13,7 +13,8 @@ class NewUserType extends AbstractType
13 { 13 {
14 $builder 14 $builder
15 ->add('username', 'text', array('required' => true)) 15 ->add('username', 'text', array('required' => true))
16 ->add('password', 'password', array( 16 ->add('plainPassword', 'repeated', array(
17 'type' => 'password',
17 'constraints' => array( 18 'constraints' => array(
18 new Constraints\Length(array( 19 new Constraints\Length(array(
19 'min' => 8, 20 'min' => 8,
@@ -30,7 +31,7 @@ class NewUserType extends AbstractType
30 public function configureOptions(OptionsResolver $resolver) 31 public function configureOptions(OptionsResolver $resolver)
31 { 32 {
32 $resolver->setDefaults(array( 33 $resolver->setDefaults(array(
33 'data_class' => 'Wallabag\CoreBundle\Entity\User', 34 'data_class' => 'Wallabag\UserBundle\Entity\User',
34 )); 35 ));
35 } 36 }
36 37
diff --git a/src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php
deleted file mode 100644
index 38f1a105..00000000
--- a/src/Wallabag/CoreBundle/Form/Type/ResetPasswordType.php
+++ /dev/null
@@ -1,35 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\Validator\Constraints;
8
9class ResetPasswordType extends AbstractType
10{
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder
14 ->add('new_password', 'repeated', array(
15 'type' => 'password',
16 'invalid_message' => 'The password fields must match.',
17 'required' => true,
18 'first_options' => array('label' => 'New password'),
19 'second_options' => array('label' => 'Repeat new password'),
20 'constraints' => array(
21 new Constraints\Length(array(
22 'min' => 8,
23 'minMessage' => 'Password should by at least 8 chars long',
24 )),
25 new Constraints\NotBlank(),
26 ),
27 ))
28 ;
29 }
30
31 public function getName()
32 {
33 return 'change_passwd';
34 }
35}
diff --git a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
index e3196d9c..84f02013 100644
--- a/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php
@@ -27,7 +27,7 @@ class UserInformationType extends AbstractType
27 public function configureOptions(OptionsResolver $resolver) 27 public function configureOptions(OptionsResolver $resolver)
28 { 28 {
29 $resolver->setDefaults(array( 29 $resolver->setDefaults(array(
30 'data_class' => 'Wallabag\CoreBundle\Entity\User', 30 'data_class' => 'Wallabag\UserBundle\Entity\User',
31 )); 31 ));
32 } 32 }
33 33