/** * @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')); }
/** * @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')); }