Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

バリデーションエラー発生後にログアウトされる件の修正 #6110

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [];
}
}
}
Loading