Skip to content

Commit

Permalink
EC-CUBE#226 【管理画面/会員編集】管理画面で退会にステータスを変更した場合、メールアドレスがランダムなものに変更されない
Browse files Browse the repository at this point in the history
  • Loading branch information
kengo-kamon committed Jul 24, 2018
1 parent 069d05c commit 405d0a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Eccube/Controller/Admin/Customer/CustomerEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
use Eccube\Controller\AbstractController;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Entity\Master\CustomerStatus;
use Eccube\Form\Type\Admin\CustomerType;
use Eccube\Repository\CustomerRepository;
use Eccube\Util\StringUtil;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -60,6 +62,8 @@ public function index(Request $request, $id = null)
if (is_null($Customer)) {
throw new NotFoundHttpException();
}

$oldStatusId = $Customer->getStatus()->getId();
// 編集用にデフォルトパスワードをセット
$previous_password = $Customer->getPassword();
$Customer->setPassword($this->eccubeConfig['eccube_default_password']);
Expand Down Expand Up @@ -103,6 +107,12 @@ public function index(Request $request, $id = null)
$Customer->setPassword($encoder->encodePassword($Customer->getPassword(), $Customer->getSalt()));
}

// 退会ステータスに更新の場合、ダミーのアドレスに更新
$newStatusId = $Customer->getStatus()->getId();
if ($oldStatusId != $newStatusId && $newStatusId == CustomerStatus::WITHDRAWING) {
$Customer->setEmail(StringUtil::random(60).'@dummy.dummy');
}

$this->entityManager->persist($Customer);
$this->entityManager->flush();

Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Controller/Mypage/WithdrawController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Eccube\Event\EventArgs;
use Eccube\Repository\Master\CustomerStatusRepository;
use Eccube\Service\MailService;
use Eccube\Util\StringUtil;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -96,6 +97,7 @@ public function index(Request $request)
// 退会ステータスに変更
$CustomerStatus = $this->customerStatusRepository->find(CustomerStatus::WITHDRAWING);
$Customer->setStatus($CustomerStatus);
$Customer->setEmail(StringUtil::random(60).'@dummy.dummy');

$this->entityManager->flush();

Expand Down

0 comments on commit 405d0a4

Please sign in to comment.