/**
  * Authenticate user
  *
  * @param \Magento\Framework\App\ActionInterface $subject
  * @param RequestInterface $request
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request)
 {
     $loginUrl = $this->customerUrl->getLoginUrl();
     if (!$this->customerSession->authenticate($loginUrl)) {
         $subject->getActionFlag()->set('', $subject::FLAG_NO_DISPATCH, true);
     }
 }
Example #2
0
 /**
  * Perform customer authentication and wishlist feature state checks
  *
  * @param \Magento\Framework\App\ActionInterface $subject
  * @param RequestInterface $request
  * @return void
  * @throws \Magento\Framework\Exception\NotFoundException
  */
 public function beforeExecute(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request)
 {
     if ($this->authenticationState->isEnabled() && !$this->customerSession->authenticate()) {
         $subject->getActionFlag()->set('', 'no-dispatch', true);
         if (!$this->customerSession->getBeforeWishlistUrl()) {
             $this->customerSession->setBeforeWishlistUrl($this->redirector->getRefererUrl());
         }
         $this->customerSession->setBeforeWishlistRequest($request->getParams());
     }
     if (!$this->config->isSetFlag('wishlist/general/active')) {
         throw new NotFoundException(__('Page not found.'));
     }
 }
Example #3
0
 /**
  * Dispatch actions allowed for not authorized users
  *
  * @param ActionInterface $subject
  * @param \Closure $proceed
  * @param RequestInterface $request
  * @return mixed
  */
 public function aroundDispatch(ActionInterface $subject, \Closure $proceed, RequestInterface $request)
 {
     $action = strtolower($request->getActionName());
     $pattern = '/^(' . implode('|', $this->allowedActions) . ')$/i';
     if (!preg_match($pattern, $action)) {
         if (!$this->session->authenticate()) {
             $subject->getActionFlag()->set('', ActionInterface::FLAG_NO_DISPATCH, true);
         }
     } else {
         $this->session->setNoReferer(true);
     }
     $result = $proceed($request);
     $this->session->unsNoReferer(false);
     return $result;
 }