/**
  * @param \Magento\Backend\App\AbstractAction $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  *
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Backend\App\AbstractAction $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     $requestedActionName = $request->getActionName();
     if (in_array($requestedActionName, $this->_openActions)) {
         $request->setDispatched(true);
     } else {
         if ($this->_auth->getUser()) {
             $this->_auth->getUser()->reload();
         }
         if (!$this->_auth->isLoggedIn()) {
             $this->_processNotLoggedInUser($request);
         } else {
             $this->_auth->getAuthStorage()->prolong();
             $backendApp = null;
             if ($request->getParam('app')) {
                 $backendApp = $this->backendAppList->getCurrentApp();
             }
             if ($backendApp) {
                 $resultRedirect = $this->resultRedirectFactory->create();
                 $baseUrl = \Magento\Framework\App\Request\Http::getUrlNoScript($this->backendUrl->getBaseUrl());
                 $baseUrl = $baseUrl . $backendApp->getStartupPage();
                 return $resultRedirect->setUrl($baseUrl);
             }
         }
     }
     $this->_auth->getAuthStorage()->refreshAcl();
     return $proceed($request);
 }
Beispiel #2
0
 public function testGetUser()
 {
     $this->_model->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
     $this->assertNotNull($this->_model->getUser());
     $this->assertGreaterThan(0, $this->_model->getUser()->getId());
     $this->assertInstanceOf('Magento\\Backend\\Model\\Auth\\Credential\\StorageInterface', $this->_model->getUser());
 }
Beispiel #3
0
 /**
  * @return int|bool
  */
 public function getCurrentUserId()
 {
     if ($this->_auth->getUser()) {
         return $this->_auth->getUser()->getId();
     }
     return false;
 }
 /**
  * @param \Magento\Backend\App\AbstractAction $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  *
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Backend\App\AbstractAction $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     $requestedActionName = $request->getActionName();
     if (in_array($requestedActionName, $this->_openActions)) {
         $request->setDispatched(true);
     } else {
         if ($this->_auth->getUser()) {
             $this->_auth->getUser()->reload();
         }
         if (!$this->_auth->isLoggedIn()) {
             $this->_processNotLoggedInUser($request);
         } else {
             $this->_auth->getAuthStorage()->prolong();
         }
     }
     $this->_auth->getAuthStorage()->refreshAcl();
     return $proceed($request);
 }
 /**
  * {@inheritdoc}
  */
 public function getUser()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getUser');
     if (!$pluginInfo) {
         return parent::getUser();
     } else {
         return $this->___callPlugins('getUser', func_get_args(), $pluginInfo);
     }
 }
 /**
  * Autorisation url for OAUTH.
  *
  * @return string
  */
 public function getAuthoriseUrl()
 {
     $clientId = $this->_scopeConfig->getValue(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CLIENT_ID);
     //callback uri if not set custom
     $redirectUri = $this->getRedirectUri();
     $redirectUri .= 'connector/email/callback';
     $adminUser = $this->auth->getUser();
     //query params
     $params = ['redirect_uri' => $redirectUri, 'scope' => 'Account', 'state' => $adminUser->getId(), 'response_type' => 'code'];
     $authorizeBaseUrl = $this->configHelper->getAuthorizeLink();
     $url = $authorizeBaseUrl . http_build_query($params) . '&client_id=' . $clientId;
     return $url;
 }
 /**
  * @return mixed
  */
 public function getCode()
 {
     return $this->auth->getUser()->getEmailCode();
 }