Пример #1
0
 /**
  * Check customer authentication for some actions
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$this->customerSession->authenticate()) {
         $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
     }
     return parent::dispatch($request);
 }
 /**
  * Dispatch request
  *
  * @param RequestInterface $request
  * @return ResponseInterface
  * @throws NotFoundException
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$this->customerSession->authenticate()) {
         $this->_actionFlag->set('', 'no-dispatch', true);
     }
     return parent::dispatch($request);
 }
 /**
  * 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);
     }
 }
Пример #4
0
 /**
  * Check customer authentication
  *
  * @param RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     $loginUrl = $this->_objectManager->get('Magento\\Customer\\Model\\Url')->getLoginUrl();
     if (!$this->_customerSession->authenticate($this, $loginUrl)) {
         $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
     }
     return parent::dispatch($request);
 }
Пример #5
0
 /**
  * Prepare wishlist for share
  *
  * @return void|\Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     if ($this->customerSession->authenticate()) {
         /** @var \Magento\Framework\View\Result\Page $resultPage */
         $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
         return $resultPage;
     }
 }
Пример #6
0
 public function testAuthenticate()
 {
     $urlMock = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
     $urlMock->expects($this->exactly(2))->method('getUrl')->will($this->returnValue(''));
     $urlMock->expects($this->once())->method('getRebuiltUrl')->will($this->returnValue(''));
     $this->urlFactoryMock->expects($this->exactly(3))->method('create')->will($this->returnValue($urlMock));
     $this->responseMock->expects($this->once())->method('setRedirect')->with('')->will($this->returnValue(''));
     $this->assertFalse($this->_model->authenticate());
 }
Пример #7
0
 /**
  * Check customer authentication for some actions
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$this->customerSession->authenticate()) {
         $this->_actionFlag->set('', 'no-dispatch', true);
         if (!$this->customerSession->getBeforeUrl()) {
             $this->customerSession->setBeforeUrl($this->_redirect->getRefererUrl());
         }
     }
     return parent::dispatch($request);
 }
Пример #8
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 beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request)
 {
     if ($this->authenticationState->isEnabled() && !$this->customerSession->authenticate($subject)) {
         $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.'));
     }
 }
Пример #9
0
 /**
  * Make sure customer is logged in and put it into registry
  *
  * @param RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$request->isDispatched()) {
         return parent::dispatch($request);
     }
     if (!$this->_customerSession->authenticate($this)) {
         $this->_actionFlag->set('', 'no-dispatch', true);
     }
     $customer = $this->_customerSession->getCustomer();
     $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $customer);
     $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId());
     return parent::dispatch($request);
 }
Пример #10
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;
 }
Пример #11
0
 /**
  * Check customer authentication
  *
  * @param RequestInterface $request
  * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     $loginUrl = $this->customerUrl->getLoginUrl();
     if (!$this->customerSession->authenticate($loginUrl)) {
         $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
     }
     if (!$this->config->useVault()) {
         $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setPath('noRoute');
         return $resultRedirect;
     }
     return parent::dispatch($request);
 }
Пример #12
0
 /**
  * Wishlist rss feed action
  * Show all public wishlists and private wishlists that belong to current user
  *
  * @return void
  */
 public function execute()
 {
     if (!$this->rssWishlistHelper->isRssAllow()) {
         $this->_forward('noroute');
         return;
     }
     /** @var \Magento\Wishlist\Model\Wishlist $wishlist */
     $wishlist = $this->wishlistProvider->getWishlist();
     if ($wishlist && ($wishlist->getVisibility() || $this->customerSession->authenticate($this) && $wishlist->getCustomerId() == $this->rssWishlistHelper->getCustomer()->getId())) {
         $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=UTF-8');
         $this->_view->loadLayout(false);
         $this->_view->renderLayout();
         return;
     }
     /** @var \Magento\Rss\Helper\Data $rssHelper */
     $rssHelper = $this->rssHelperFactory->create();
     $rssHelper->sendEmptyRssFeed($this->getResponse());
 }