mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-26 18:21:02 +00:00
material design for register/login/recover pages
This commit is contained in:
parent
4c5e544183
commit
ec3ce598f6
29 changed files with 385 additions and 338 deletions
75
src/Wallabag/UserBundle/Controller/ResettingController.php
Normal file
75
src/Wallabag/UserBundle/Controller/ResettingController.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\UserBundle\Controller;
|
||||
|
||||
use FOS\UserBundle\FOSUserEvents;
|
||||
use FOS\UserBundle\Event\FormEvent;
|
||||
use FOS\UserBundle\Event\GetResponseUserEvent;
|
||||
use FOS\UserBundle\Event\FilterUserResponseEvent;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class ResettingController extends \FOS\UserBundle\Controller\ResettingController
|
||||
{
|
||||
/**
|
||||
* Extends ResettingController to change the redirection after success.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $token
|
||||
*
|
||||
* @return null|RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function resetAction(Request $request, $token)
|
||||
{
|
||||
/** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
|
||||
$formFactory = $this->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(),
|
||||
));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue