diff --git a/src/Controller/Subscriber/Confirm.php b/src/Controller/Subscriber/Confirm.php new file mode 100644 index 0000000..77cf0c6 --- /dev/null +++ b/src/Controller/Subscriber/Confirm.php @@ -0,0 +1,36 @@ +getRequest()->getParam('id'); + $code = (string)$this->getRequest()->getParam('code'); + + if ($id && $code) { + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $this->_subscriberFactory->create()->load($id); + + if ($subscriber->getId() && $subscriber->getCode()) { + if ($subscriber->confirm($code)) { + $this->messageManager->addSuccessMessage(__('Your subscription has been confirmed.')); + } else { + $this->messageManager->addErrorMessage(__('This is an invalid subscription confirmation code.')); + } + } else { + $this->messageManager->addErrorMessage(__('This is an invalid subscription ID.')); + } + } + /** @var \Magento\Framework\Controller\Result\Redirect $redirect */ + $redirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT); + $redirectUrl = $this->_storeManager->getStore()->getBaseUrl().'newsletter/confirm/id/'.$id.'/code/'.$code; + return $redirect->setUrl($redirectUrl); + } +} diff --git a/src/etc/di.xml b/src/etc/di.xml index 9d3d088..3368461 100644 --- a/src/etc/di.xml +++ b/src/etc/di.xml @@ -22,6 +22,8 @@ type="ScandiPWA\CustomerGraphQl\Model\Customer\CheckCustomerPassword"/> + ScandiPWA\CustomerGraphQl\Model\Session diff --git a/src/etc/module.xml b/src/etc/module.xml index ca1c2da..7d75f93 100755 --- a/src/etc/module.xml +++ b/src/etc/module.xml @@ -19,6 +19,7 @@ +