Skip to content

Commit

Permalink
Merge pull request #6110 from dotani1111/fix/logout_on_validation_error
Browse files Browse the repository at this point in the history
バリデーションエラー発生後にログアウトされる件の修正
  • Loading branch information
ji-eunsoo committed Apr 1, 2024
2 parents 7786521 + 9418803 commit 28e3db6
Showing 1 changed file with 40 additions and 35 deletions.
75 changes: 40 additions & 35 deletions src/Eccube/Controller/Mypage/ChangeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,45 @@ public function index(Request $request)
$form = $builder->getForm();
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
log_info('会員編集開始');

if ($Customer->getPlainPassword() !== $this->eccubeConfig['eccube_default_password']) {
$password = $this->passwordHasher->hashPassword($Customer, $Customer->getPlainPassword());
$Customer->setPassword($password);
if ($form->isSubmitted()) {
if ($form->isValid()) {
log_info('会員編集開始');

if ($Customer->getPlainPassword() !== $this->eccubeConfig['eccube_default_password']) {
$password = $this->passwordHasher->hashPassword($Customer, $Customer->getPlainPassword());
$Customer->setPassword($password);
}

// 会員情報変更時にメールを送信
if ($this->baseInfoRepository->get()->isOptionMailNotifier()) {
// 情報のセット
$userData['userAgent'] = $request->headers->get('User-Agent');
$userData['preEmail'] = $request->getSession()->get(self::SESSION_KEY_PRE_EMAIL);
$userData['ipAddress'] = $request->getClientIp();

// メール送信
$this->mailService->sendCustomerChangeNotifyMail($Customer, $userData, trans('front.mypage.customer.notify_title'));
}

$this->session->remove(self::SESSION_KEY_PRE_EMAIL);

$this->entityManager->flush();

log_info('会員編集完了');

$event = new EventArgs(
[
'form' => $form,
'Customer' => $Customer,
],
$request
);
$this->eventDispatcher->dispatch($event, EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_COMPLETE);

return $this->redirect($this->generateUrl('mypage_change_complete'));
}

// 会員情報変更時にメールを送信
if ($this->baseInfoRepository->get()->isOptionMailNotifier()) {
// 情報のセット
$userData['userAgent'] = $request->headers->get('User-Agent');
$userData['preEmail'] = $request->getSession()->get(self::SESSION_KEY_PRE_EMAIL);
$userData['ipAddress'] = $request->getClientIp();

// メール送信
$this->mailService->sendCustomerChangeNotifyMail($Customer, $userData, trans('front.mypage.customer.notify_title'));
}

$this->session->remove(self::SESSION_KEY_PRE_EMAIL);

$this->entityManager->flush();

log_info('会員編集完了');

$event = new EventArgs(
[
'form' => $form,
'Customer' => $Customer,
],
$request
);
$this->eventDispatcher->dispatch($event, EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_COMPLETE);

return $this->redirect($this->generateUrl('mypage_change_complete'));
// see https://github.com/EC-CUBE/ec-cube/issues/6103
$this->entityManager->refresh($Customer);
}

$preEmail = $form->get('email')->getData();
Expand All @@ -148,10 +152,11 @@ public function index(Request $request)
* 会員情報編集完了画面.
*
* @Route("/mypage/change_complete", name="mypage_change_complete", methods={"GET"})
*
* @Template("Mypage/change_complete.twig")
*/
public function complete(Request $request)
{
return [];
}
}
}

0 comments on commit 28e3db6

Please sign in to comment.