Example #1
0
 /**
  * Authentication to downloader
  *
  * @return $this
  */
 public function authenticate()
 {
     if (!$this->_session) {
         return $this;
     }
     if (!empty($_GET['return'])) {
         $this->set('return_url', $_GET['return']);
     }
     if ($this->_checkUserAccess()) {
         return $this;
     }
     if (!$this->controller()->isInstalled()) {
         return $this;
     }
     try {
         if (isset($_POST['username']) && empty($_POST['username']) || isset($_POST['password']) && empty($_POST['password'])) {
             $this->addMessage('error', 'Invalid user name or password');
         }
         if (empty($_POST['username']) || empty($_POST['password'])) {
             $this->controller()->setAction('login');
             return $this;
         }
         $user = $this->_session->login($_POST['username'], $_POST['password']);
         $this->_session->refreshAcl();
         if ($this->_checkUserAccess($user)) {
             return $this;
         }
     } catch (\Exception $e) {
         $this->addMessage('error', $e->getMessage());
     }
     $this->controller()->redirect($this->controller()->url('loggedin'), true);
 }
Example #2
0
 /**
  * @dataProvider refreshAclDataProvider
  * @param $isUserPassedViaParams
  */
 public function testRefreshAcl($isUserPassedViaParams)
 {
     $aclMock = $this->getMockBuilder('Magento\\Framework\\Acl')->disableOriginalConstructor()->getMock();
     $this->aclBuilder->expects($this->any())->method('getAcl')->willReturn($aclMock);
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->setMethods(['getReloadAclFlag', 'setReloadAclFlag', 'unsetData', 'save'])->disableOriginalConstructor()->getMock();
     $userMock->expects($this->any())->method('getReloadAclFlag')->willReturn(true);
     $userMock->expects($this->once())->method('setReloadAclFlag')->with('0')->willReturnSelf();
     $userMock->expects($this->once())->method('save');
     $this->storage->expects($this->once())->method('setAcl')->with($aclMock);
     $this->storage->expects($this->any())->method('getAcl')->willReturn($aclMock);
     if ($isUserPassedViaParams) {
         $this->session->refreshAcl($userMock);
     } else {
         $this->storage->expects($this->once())->method('getUser')->willReturn($userMock);
         $this->session->refreshAcl();
     }
     $this->assertSame($aclMock, $this->session->getAcl());
 }
 /**
  * {@inheritdoc}
  */
 public function refreshAcl($user = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'refreshAcl');
     if (!$pluginInfo) {
         return parent::refreshAcl($user);
     } else {
         return $this->___callPlugins('refreshAcl', func_get_args(), $pluginInfo);
     }
 }