public function reset(Application $app, Request $request, $reset_key)
{
$errors = $app['validator']->validateValue($reset_key, array(new Assert\NotBlank(), new Assert\Regex(array('pattern' => '/^[a-zA-Z0-9]+$/'))));
if ('GET' === $request->getMethod() && count($errors) === 0) {
try {
$Customer = $app['eccube.repository.customer']->getActiveCustomerByResetKey($reset_key);
} catch (\Exception $e) {
throw new HttpException\NotFoundHttpException('有効期限が切れているか、無効なURLです。');
}
// パスワードの発行・更新
$pass = $app['eccube.repository.customer']->getResetPassword();
$Customer->setPassword($pass);
// 発行したパスワードの暗号化
if ($Customer->getSalt() === null) {
$Customer->setSalt($app['eccube.repository.customer']->createSalt(5));
}
$encPass = $app['eccube.repository.customer']->encryptPassword($app, $Customer);
$Customer->setPassword($encPass);
$Customer->setResetKey(null);
// パスワードを更新
$app['orm.em']->persist($Customer);
$app['orm.em']->flush();
$event = new EventArgs(array('Customer' => $Customer), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_FORGOT_RESET_COMPLETE, $event);
// メール送信
$app['eccube.service.mail']->sendPasswordResetCompleteMail($Customer, $pass);
// ログ出力
$app['monolog']->addInfo('reset password complete:' . "{$Customer->getId()} {$Customer->getEmail()} {$request->getClientIp()}");
} else {
throw new HttpException\AccessDeniedHttpException('不正なアクセスです。');
}
return $app->render('Forgot/reset.twig');
}