From 6894d48e03c397096bb64420373afa60c397fe97 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 7 Mar 2015 23:25:36 +0100 Subject: Handle forgot password --- .../CoreBundle/Form/Type/ForgotPasswordType.php | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php (limited to 'src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php') diff --git a/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php new file mode 100644 index 00000000..c278b84f --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/ForgotPasswordType.php @@ -0,0 +1,52 @@ +doctrine = $doctrine; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('email', 'email', array( + 'constraints' => array( + new Constraints\Email(), + new Constraints\NotBlank(), + new Constraints\Callback(array(array($this, 'validateEmail'))), + ), + )) + ; + } + + public function getName() + { + return 'forgot_password'; + } + + public function validateEmail($email, ExecutionContextInterface $context) + { + $user = $this->doctrine + ->getRepository('WallabagCoreBundle:User') + ->findOneByEmail($email); + + if (!$user) { + $context->addViolationAt( + 'email', + 'No user found with this email', + array(), + $email + ); + } + } +} -- cgit v1.2.3