105 $this->session = $customerSession;
120 public function getRedirect()
126 if ($this->session->getBeforeRequestParams()) {
128 $result->setParams($this->session->getBeforeRequestParams())
129 ->setModule($this->session->getBeforeModuleName())
130 ->setController($this->session->getBeforeControllerName())
131 ->forward($this->session->getBeforeAction());
134 $result->setUrl($this->session->getBeforeAuthUrl(
true));
146 $lastCustomerId = $this->session->getLastCustomerId();
147 if (isset($lastCustomerId)
148 && $this->session->isLoggedIn()
149 && $lastCustomerId != $this->session->getId()
151 $this->session->unsBeforeAuthUrl()
152 ->setLastCustomerId($this->session->getId());
163 $baseUrl = $this->storeManager->getStore()->getBaseUrl();
165 $url = $this->session->getBeforeAuthUrl();
172 if ($this->session->isLoggedIn()) {
175 $this->applyRedirect($this->customerUrl->getLoginUrl());
179 case $this->customerUrl->getLogoutUrl():
180 $this->applyRedirect($this->customerUrl->getDashboardUrl());
184 if (!$this->session->getAfterAuthUrl()) {
185 $this->session->setAfterAuthUrl($this->session->getBeforeAuthUrl());
187 if ($this->session->isLoggedIn()) {
188 $this->applyRedirect($this->session->getAfterAuthUrl(
true));
204 $this->applyRedirect($this->customerUrl->getAccountUrl());
206 if (!$this->scopeConfig->isSetFlag(
207 CustomerUrl::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD,
211 $referer = $this->request->getParam(CustomerUrl::REFERER_QUERY_PARAM_NAME);
213 $referer = $this->urlDecoder->decode($referer);
214 preg_match(
'/logoutSuccess\//', $referer, $matches, PREG_OFFSET_CAPTURE);
215 if (!empty($matches)) {
216 $referer = str_replace(
'logoutSuccess/',
'', $referer);
218 if ($this->hostChecker->isOwnOrigin($referer)) {
219 $this->applyRedirect($referer);
222 }
elseif ($this->session->getAfterAuthUrl()) {
223 $this->applyRedirect($this->session->getAfterAuthUrl(
true));
233 private function applyRedirect(
$url)
235 $this->session->setBeforeAuthUrl(
$url);
246 if (!is_object($this->cookieManager)) {
261 $this->cookieManager =
$value;
271 return $this->
getCookieManager()->getCookie(self::LOGIN_REDIRECT_URL,
null);
282 $this->
getCookieManager()->setPublicCookie(self::LOGIN_REDIRECT_URL, $route);
elseif(isset( $params[ 'redirect_parent']))
setRedirectCookie($route)
__construct(RequestInterface $request, Session $customerSession, ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager, UrlInterface $url, DecoderInterface $urlDecoder, CustomerUrl $customerUrl, ResultFactory $resultFactory, HostChecker $hostChecker=null)