当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::authenticate方法代码示例

本文整理汇总了PHP中Magento\Customer\Model\Session::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::authenticate方法的具体用法?PHP Session::authenticate怎么用?PHP Session::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Customer\Model\Session的用法示例。


在下文中一共展示了Session::authenticate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dispatch

 /**
  * 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);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Customer.php

示例2: dispatch

 /**
  * 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);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:14,代码来源:CardsManagement.php

示例3: beforeDispatch

 /**
  * 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);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Authentication.php

示例4: dispatch

 /**
  * 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);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Products.php

示例5: execute

 /**
  * 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;
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Share.php

示例6: testAuthenticate

 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());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:SessionTest.php

示例7: dispatch

 /**
  * 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);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Add.php

示例8: beforeDispatch

 /**
  * 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.'));
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:21,代码来源:Plugin.php

示例9: dispatch

 /**
  * 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);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:19,代码来源:RecurringPayment.php

示例10: aroundDispatch

 /**
  * 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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:23,代码来源:Account.php

示例11: dispatch

 /**
  * 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);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:MyCreditCards.php

示例12: execute

 /**
  * 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());
 }
开发者ID:aiesh,项目名称:magento2,代码行数:24,代码来源:Rss.php


注:本文中的Magento\Customer\Model\Session::authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。