symfony2ユーザーリセットパスワードのリセットアクションを書きました。コードは次のとおりです。
/**
* @Route("/reset-password/{confirmationToken}", name="user_resetting_confirm")
* @ParamConverter("confirmationToken", class="MyProjectBundle:User")
* @param \My\Project\Entity\User $user
* @Template()
*/
public function resetAction(Request $request, $confirmationToken)
{
$form = $this->createFormBuilder()
->add('password', 'repeated', array(
'type' => 'password',
'first_name' => 'New Password',
'second_name' => 'Confirm New Password',
'invalid_message' => 'Passwords don\'t match',
'error_bubbling' => true,
))
->getForm();
if ('POST' == $request->getMethod()) {
$form->bindRequest($request);
$data = $form->getData();
$user = $this->container->get('fos_user.user_manager')->findUserByConfirmationToken($confirmationToken);
if (null === $user) {
throw new NotFoundHttpException(sprintf('The user with "confirmation token" does not exist for value "%s"', $confirmationToken));
}
if (!$user->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl'))) {
return new RedirectResponse($this->container->get('router')->generate('fos_user_resetting_request'));
}
if ($form->isValid()) {
$newPassword = $data['password'];
$factory = $this->get('security.encoder_factory');
$encoder = $factory->getEncoder($user);
$password = $encoder->encodePassword($newPassword, $user->getSalt());
$user->setPassword($password);
$em = $this->get('doctrine')->getEntityManager();
$em->persist($user);
$em->flush();
$this->authenticateUser($user);
return new RedirectResponse($this->getRedirectionUrl($user));
}
}
return $this->render('MyProjectBundle:Resetting:password_reset.html.twig',array('form' => $form->createView()));
}
何らかの理由で、両方のフィールドに間違ったパスワードを入力してから送信すると、HTMLコードのない空白のページが表示されます。ここで何か間違っていることはありますか?