public function resettingRequest(User $user)
 {
     self::persistAndFlush($user);
     $userEvent = new UserEvent($user);
     $userEvent->setSecureArea($user->getAdminUser())->setParams(array($userEvent::PARAM_RESETTING_EMAIL_ROUTE => 'admin_security_resetting_reset', $userEvent::PARAM_RESETTING_EMAIL_FROM => 'security.resetting_email.from', $userEvent::PARAM_RESETTING_EMAIL_TEMPLATE => 'admin/security/resetting/email.html.twig'));
     $this->eventDispatcher->dispatch(UserEvents::RESETTING_REQUEST_SUCCESS, $userEvent);
 }
 /**
  * @param UserEvent $event
  * @throws \Exception
  * @throws \Twig_Error
  */
 public function onResettingRequestSuccess(UserEvent $event)
 {
     $user = $event->getUser();
     $params = $event->getParams();
     $url = $this->router->generate($params[$event::PARAM_RESETTING_EMAIL_ROUTE], array('token' => $user->getConfirmationToken()), true);
     $message = \Swift_Message::newInstance()->setSubject($this->translator->trans('security.resetting.request.email.subject'))->setFrom($this->parameter->get($params[$event::PARAM_RESETTING_EMAIL_FROM]))->setTo($user->getEmail())->setBody($this->twigEngine->render($params[$event::PARAM_RESETTING_EMAIL_TEMPLATE], array('complete_name' => $event->getSecureArea()->getCompleteName(), 'url' => $url)));
     $this->mailer->send($message);
     $this->flashBag->add(FlashBagEvents::MESSAGE_TYPE_SUCCESS, $this->translator->trans('security.resetting.request.check_email', array('user_email' => $user->getObfuscatedEmail())));
 }
 /**
  * @Route("/resetting/reset/{token}", name="admin_security_resetting_reset")
  * @Method({"GET", "POST"})
  */
 public function resettingResetAction(Request $request, $token)
 {
     $userEvent = new UserEvent((new User())->setConfirmationToken($token));
     $userEvent->setManager($this->get('app.admin_user_manager'));
     $this->get('event_dispatcher')->dispatch(UserEvents::RESETTING_RESET_INITIALIZE, $userEvent);
     if ($userEvent->getHasError()) {
         return $this->redirectToRoute('admin_security_login');
     }
     $form = $this->createForm(new ResettingResetType(), $userEvent->getUser());
     $formHandler = $this->get('app.admin_resetting_reset_form_handler');
     if ($formHandler->handle($form, $request)) {
         return $this->redirectToRoute('admin_security_login');
     }
     return $this->render('admin/security/resetting/resettingReset.html.twig', array('form' => $form->createView(), 'token' => $token));
 }
 public function onResettingResetSuccess(UserEvent $event)
 {
     $user = $event->getUser();
     $user->setPasswordRequestedAt(null)->setConfirmationToken(null);
 }