本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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());
}
示例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);
}
示例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.'));
}
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}