/** * Performs redirect to login for checkout * @param RedirectLoginInterface $expressRedirect * @param string|null $customerBeforeAuthUrlDefault * @return void */ public function redirectLogin(RedirectLoginInterface $expressRedirect, $customerBeforeAuthUrlDefault = null) { $this->_actionFlag->set('', 'no-dispatch', true); foreach ($expressRedirect->getActionFlagList() as $actionKey => $actionFlag) { $this->_actionFlag->set('', $actionKey, $actionFlag); } $expressRedirect->getResponse()->setRedirect($this->_objectManager->get('Magento\\Framework\\Url\\Helper\\Data')->addRequestParam($expressRedirect->getLoginUrl(), ['context' => 'checkout'])); $customerBeforeAuthUrl = $customerBeforeAuthUrlDefault; if ($expressRedirect->getCustomerBeforeAuthUrl()) { $customerBeforeAuthUrl = $expressRedirect->getCustomerBeforeAuthUrl(); } if ($customerBeforeAuthUrl) { $this->_customerSession->setBeforeAuthUrl($customerBeforeAuthUrl); } }
/** * Dispatch request * * @param RequestInterface $request * @return \Magento\Framework\App\ResponseInterface */ public function dispatch(RequestInterface $request) { $allowGuest = $this->_objectManager->get('Magento\\Review\\Helper\\Data')->getIsGuestAllowToWrite(); if (!$request->isDispatched()) { return parent::dispatch($request); } if (!$allowGuest && $request->getActionName() == 'post' && $request->isPost()) { if (!$this->_customerSession->isLoggedIn()) { $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); $this->_customerSession->setBeforeAuthUrl($this->_url->getUrl('*/*/*', ['_current' => true])); $this->_reviewSession->setFormData($request->getPostValue())->setRedirectUrl($this->_redirect->getRefererUrl()); $this->getResponse()->setRedirect($this->_objectManager->get('Magento\\Customer\\Model\\Url')->getLoginUrl()); } } return parent::dispatch($request); }
/** * Redirect to login page * * @return void */ public function redirectLogin() { $this->_actionFlag->set('', 'no-dispatch', true); $this->_customerSession->setBeforeAuthUrl($this->_redirect->getRefererUrl()); $this->getResponse()->setRedirect($this->_urlHelper->addRequestParam($this->_customerUrl->getLoginUrl(), ['context' => 'checkout'])); }