Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Feed.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Rss\Controller;
7 
12 {
16  protected $customerSession;
17 
22 
27 
31  protected $logger;
32 
36  protected $rssManager;
37 
41  protected $rssFactory;
42 
46  protected $scopeConfig;
47 
58  public function __construct(
59  \Magento\Framework\App\Action\Context $context,
60  \Magento\Rss\Model\RssManager $rssManager,
61  \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
62  \Magento\Rss\Model\RssFactory $rssFactory,
63  \Magento\Customer\Model\Session $customerSession,
64  \Magento\Customer\Api\AccountManagementInterface $customerAccountManagement,
65  \Magento\Framework\HTTP\Authentication $httpAuthentication,
66  \Psr\Log\LoggerInterface $logger
67  ) {
68  $this->rssManager = $rssManager;
69  $this->scopeConfig = $scopeConfig;
70  $this->rssFactory = $rssFactory;
71  $this->customerSession = $customerSession;
72  $this->customerAccountManagement = $customerAccountManagement;
73  $this->httpAuthentication = $httpAuthentication;
74  $this->logger = $logger;
75  parent::__construct($context);
76  }
77 
81  protected function auth()
82  {
83  if (!$this->customerSession->isLoggedIn()) {
84  list($login, $password) = $this->httpAuthentication->getCredentials();
85  try {
86  $customer = $this->customerAccountManagement->authenticate($login, $password);
87  $this->customerSession->setCustomerDataAsLoggedIn($customer);
88  $this->customerSession->regenerateId();
89  } catch (\Exception $e) {
90  $this->logger->critical($e);
91  }
92  }
93 
94  if (!$this->customerSession->isLoggedIn()) {
95  $this->httpAuthentication->setAuthenticationFailed('RSS Feeds');
96  return false;
97  }
98 
99  return true;
100  }
101 }
$customer
Definition: customers.php:11
__construct(\Magento\Framework\App\Action\Context $context, \Magento\Rss\Model\RssManager $rssManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Rss\Model\RssFactory $rssFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Api\AccountManagementInterface $customerAccountManagement, \Magento\Framework\HTTP\Authentication $httpAuthentication, \Psr\Log\LoggerInterface $logger)
Definition: Feed.php:58