/** * @param \Magento\Backend\Model\Auth $authModel * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterLogin(\Magento\Backend\Model\Auth $authModel) { $this->sessionsManager->processLogin(); if ($this->sessionsManager->getCurrentSession()->isOtherSessionsTerminated()) { $this->messageManager->addWarning(__('All other open sessions for this account were terminated.')); } }
/** * Add user logout notification * * @return $this */ protected function addUserLogoutNotification() { if ($this->isAjaxRequest()) { $this->securityCookieHelper->setLogoutReasonCookie($this->sessionsManager->getCurrentSession()->getStatus()); } else { $this->messageManager->addError($this->sessionsManager->getLogoutReasonMessage()); } return $this; }
/** * Test of prolong user action * * @magentoDbIsolation enabled */ public function testProcessProlong() { $this->auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD); $sessionId = $this->authSession->getSessionId(); $dateInPast = $this->dateTime->formatDate($this->authSession->getUpdatedAt() - 100); $this->adminSessionsManager->getCurrentSession()->setData('updated_at', $dateInPast)->save(); $this->adminSessionInfo->load($sessionId, 'session_id'); $oldUpdatedAt = $this->adminSessionInfo->getUpdatedAt(); $this->authSession->prolong(); $this->adminSessionInfo->load($sessionId, 'session_id'); $updatedAt = $this->adminSessionInfo->getUpdatedAt(); $this->assertGreaterThan($oldUpdatedAt, $updatedAt); }
/** * Test if current session is retrieved * * @magentoDbIsolation enabled */ public function testGetCurrentSession() { $this->auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD); $sessionId = $this->authSession->getSessionId(); $this->adminSessionInfo->load($sessionId, 'session_id'); $this->assertEquals($this->adminSessionInfo->getSessionId(), $this->adminSessionsManager->getCurrentSession()->getSessionId()); }
/** * @return void */ public function testGetCurrentSession() { $sessionId = 50; $this->adminSessionInfoFactoryMock->expects($this->any())->method('create')->willReturn($this->currentSessionMock); $this->authSessionMock->expects($this->once())->method('getSessionId')->willReturn($sessionId); $this->currentSessionMock->expects($this->once())->method('load')->willReturnSelf(); $this->assertEquals($this->currentSessionMock, $this->model->getCurrentSession()); }
/** * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { /** @var \Magento\Framework\Controller\Result\Json $resultJson */ return $this->jsonFactory->create()->setData(['isActive' => $this->sessionsManager->getCurrentSession()->isLoggedInStatus()]); }