Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Authentication.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
16  protected $customerUrl;
17 
21  protected $customerSession;
22 
27  public function __construct(
28  \Magento\Customer\Model\Url $customerUrl,
29  \Magento\Customer\Model\Session $customerSession
30  ) {
31  $this->customerUrl = $customerUrl;
32  $this->customerSession = $customerSession;
33  }
34 
43  public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request)
44  {
45  $loginUrl = $this->customerUrl->getLoginUrl();
46 
47  if (!$this->customerSession->authenticate($loginUrl)) {
48  $subject->getActionFlag()->set('', $subject::FLAG_NO_DISPATCH, true);
49  }
50  }
51 }
beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request)
__construct(\Magento\Customer\Model\Url $customerUrl, \Magento\Customer\Model\Session $customerSession)