|
6 | 6 | */
|
7 | 7 | namespace Magento\Customer\Controller\Account;
|
8 | 8 |
|
9 |
| -use Magento\Customer\Model\Url; |
10 |
| -use Magento\Framework\App\Action\Context; |
11 |
| -use Magento\Customer\Model\Session; |
12 |
| -use Magento\Framework\App\Config\ScopeConfigInterface; |
13 |
| -use Magento\Store\Model\StoreManagerInterface; |
14 | 9 | use Magento\Customer\Api\AccountManagementInterface;
|
15 | 10 | use Magento\Customer\Api\CustomerRepositoryInterface;
|
| 11 | +use Magento\Customer\Controller\AbstractAccount; |
16 | 12 | use Magento\Customer\Helper\Address;
|
| 13 | +use Magento\Customer\Model\Session; |
| 14 | +use Magento\Customer\Model\Url; |
| 15 | +use Magento\Framework\App\Action\Context; |
| 16 | +use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; |
| 17 | +use Magento\Framework\App\Config\ScopeConfigInterface; |
| 18 | +use Magento\Framework\Controller\ResultFactory; |
17 | 19 | use Magento\Framework\UrlFactory;
|
18 | 20 | use Magento\Framework\Exception\StateException;
|
19 | 21 | use Magento\Store\Model\ScopeInterface;
|
20 |
| -use Magento\Framework\Controller\ResultFactory; |
| 22 | +use Magento\Store\Model\StoreManagerInterface; |
21 | 23 |
|
22 | 24 | /**
|
23 | 25 | * Class Confirm
|
24 | 26 | *
|
25 | 27 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
26 | 28 | */
|
27 |
| -class Confirm extends \Magento\Customer\Controller\AbstractAccount |
| 29 | +class Confirm extends AbstractAccount implements HttpGetActionInterface |
28 | 30 | {
|
29 | 31 | /**
|
30 | 32 | * @var \Magento\Framework\App\Config\ScopeConfigInterface
|
@@ -147,13 +149,16 @@ public function execute()
|
147 | 149 | $resultRedirect->setPath('*/*/');
|
148 | 150 | return $resultRedirect;
|
149 | 151 | }
|
150 |
| - try { |
151 |
| - $customerId = $this->getRequest()->getParam('id', false); |
152 |
| - $key = $this->getRequest()->getParam('key', false); |
153 |
| - if (empty($customerId) || empty($key)) { |
154 |
| - throw new \Exception(__('Bad request.')); |
155 |
| - } |
156 | 152 |
|
| 153 | + $customerId = $this->getRequest()->getParam('id', false); |
| 154 | + $key = $this->getRequest()->getParam('key', false); |
| 155 | + if (empty($customerId) || empty($key)) { |
| 156 | + $this->messageManager->addErrorMessage(__('Bad request.')); |
| 157 | + $url = $this->urlModel->getUrl('*/*/index', ['_secure' => true]); |
| 158 | + return $resultRedirect->setUrl($this->_redirect->error($url)); |
| 159 | + } |
| 160 | + |
| 161 | + try { |
157 | 162 | // log in and send greeting email
|
158 | 163 | $customerEmail = $this->customerRepository->getById($customerId)->getEmail();
|
159 | 164 | $customer = $this->customerAccountManagement->activate($customerEmail, $key);
|
|
0 commit comments