Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Login.php
Go to the documentation of this file.
1 <?php
8 
11 
16 class Login extends \Magento\Backend\Controller\Adminhtml\Auth implements HttpGet, HttpPost
17 {
21  protected $resultPageFactory;
22 
29  public function __construct(
30  \Magento\Backend\App\Action\Context $context,
31  \Magento\Framework\View\Result\PageFactory $resultPageFactory
32  ) {
33  $this->resultPageFactory = $resultPageFactory;
34  parent::__construct($context);
35  }
36 
42  public function execute()
43  {
44  if ($this->_auth->isLoggedIn()) {
45  if ($this->_auth->getAuthStorage()->isFirstPageAfterLogin()) {
46  $this->_auth->getAuthStorage()->setIsFirstPageAfterLogin(true);
47  }
48  return $this->getRedirect($this->_backendUrl->getStartupPageUrl());
49  }
50 
51  $requestUrl = $this->getRequest()->getUri();
52  $backendUrl = $this->getUrl('*');
53  // redirect according to rewrite rule
54  if ($requestUrl != $backendUrl) {
55  return $this->getRedirect($backendUrl);
56  }
57  return $this->resultPageFactory->create();
58  }
59 
66  private function getRedirect($path)
67  {
69  $resultRedirect = $this->resultRedirectFactory->create();
70  $resultRedirect->setPath($path);
71  return $resultRedirect;
72  }
73 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory)
Definition: Login.php:29