Esempio n. 1
0
 /**
  * @param Request $request
  * @param RequestConfiguration $configuration
  * @param UserInterface $user
  * @param string $newPassword
  *
  * @return RedirectResponse
  */
 protected function handleResetPassword(Request $request, RequestConfiguration $configuration, UserInterface $user, $newPassword)
 {
     $user->setPlainPassword($newPassword);
     $user->setPasswordResetToken(null);
     $user->setPasswordRequestedAt(null);
     $dispatcher = $this->container->get('event_dispatcher');
     $dispatcher->dispatch(UserEvents::PRE_PASSWORD_RESET, new GenericEvent($user));
     $this->manager->flush();
     $this->addFlash('success', 'sylius.user.password.reset.success');
     $dispatcher->dispatch(UserEvents::POST_PASSWORD_RESET, new GenericEvent($user));
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
     }
     $redirectRouteName = $request->attributes->get('_sylius[redirect]', 'sylius_user_security_login', true);
     return new RedirectResponse($this->container->get('router')->generate($redirectRouteName));
 }
Esempio n. 2
0
 /**
  * @param UserInterface $user
  * @param string        $newPassword
  *
  * @return RedirectResponse
  */
 protected function handleResetPassword(UserInterface $user, $newPassword)
 {
     $user->setPlainPassword($newPassword);
     $user->setConfirmationToken(null);
     $user->setPasswordRequestedAt(null);
     $this->domainManager->update($user);
     $dispatcher = $this->get('event_dispatcher');
     $dispatcher->dispatch(UserEvents::PASSWORD_RESET_SUCCESS, new GenericEvent($user));
     if ($this->config->isApiRequest()) {
         return $this->handleView($this->view($user, 204));
     }
     $this->addFlash('success', 'sylius.user.password.change.success');
     return new RedirectResponse($this->generateUrl('sylius_user_security_login'));
 }
Esempio n. 3
0
 /**
  * @param RequestConfiguration $configuration
  * @param UserInterface $user
  * @param string $newPassword
  *
  * @return RedirectResponse
  */
 protected function handleResetPassword(RequestConfiguration $configuration, UserInterface $user, $newPassword)
 {
     $user->setPlainPassword($newPassword);
     $user->setConfirmationToken(null);
     $user->setPasswordRequestedAt(null);
     $dispatcher = $this->container->get('event_dispatcher');
     $dispatcher->dispatch(UserEvents::PRE_PASSWORD_RESET, new GenericEvent($user));
     $this->manager->flush();
     $this->addFlash('success', 'sylius.user.password.reset.success');
     $dispatcher->dispatch(UserEvents::POST_PASSWORD_RESET, new GenericEvent($user));
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle($configuration, View::create($user, 204));
     }
     return new RedirectResponse($this->container->get('router')->generate('sylius_user_security_login'));
 }