From 94188030757482c110d82f41dc619a22f494276a Mon Sep 17 00:00:00 2001 From: daichi_otani Date: Thu, 7 Mar 2024 16:30:23 +0900 Subject: [PATCH] =?UTF-8?q?fix:=E4=B8=80=E5=BA=A6=E3=83=AA=E3=83=95?= =?UTF-8?q?=E3=83=AC=E3=83=83=E3=82=B7=E3=83=A5=E3=81=99=E3=82=8B=E6=A7=98?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/Mypage/ChangeController.php | 75 ++++++++++--------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/src/Eccube/Controller/Mypage/ChangeController.php b/src/Eccube/Controller/Mypage/ChangeController.php index ce6142f79d1..b912395b3d1 100644 --- a/src/Eccube/Controller/Mypage/ChangeController.php +++ b/src/Eccube/Controller/Mypage/ChangeController.php @@ -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(); @@ -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 []; } -} +} \ No newline at end of file