From ec3ce598f6423fcccd88a4fdd77f817c50bc5ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 5 Oct 2015 22:16:18 +0200 Subject: material design for register/login/recover pages --- .../UserBundle/Controller/ResettingController.php | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/Wallabag/UserBundle/Controller/ResettingController.php (limited to 'src/Wallabag/UserBundle/Controller') diff --git a/src/Wallabag/UserBundle/Controller/ResettingController.php b/src/Wallabag/UserBundle/Controller/ResettingController.php new file mode 100644 index 00000000..8aa1e230 --- /dev/null +++ b/src/Wallabag/UserBundle/Controller/ResettingController.php @@ -0,0 +1,75 @@ +get('fos_user.resetting.form.factory'); + /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ + $userManager = $this->get('fos_user.user_manager'); + /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */ + $dispatcher = $this->get('event_dispatcher'); + + $user = $userManager->findUserByConfirmationToken($token); + + if (null === $user) { + throw new NotFoundHttpException(sprintf('The user with "confirmation token" does not exist for value "%s"', $token)); + } + + $event = new GetResponseUserEvent($user, $request); + $dispatcher->dispatch(FOSUserEvents::RESETTING_RESET_INITIALIZE, $event); + + if (null !== $event->getResponse()) { + return $event->getResponse(); + } + + $form = $formFactory->createForm(); + $form->setData($user); + + $form->handleRequest($request); + + if ($form->isValid()) { + $event = new FormEvent($form, $request); + $dispatcher->dispatch(FOSUserEvents::RESETTING_RESET_SUCCESS, $event); + + $userManager->updateUser($user); + + if (null === $response = $event->getResponse()) { + $this->get('session')->getFlashBag()->add( + 'notice', + 'Password updated' + ); + $url = $this->generateUrl('homepage'); + $response = new RedirectResponse($url); + } + + $dispatcher->dispatch(FOSUserEvents::RESETTING_RESET_COMPLETED, new FilterUserResponseEvent($user, $request, $response)); + + return $response; + } + + return $this->render('FOSUserBundle:Resetting:reset.html.twig', array( + 'token' => $token, + 'form' => $form->createView(), + )); + } +} -- cgit v1.2.3