/** * 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); }
/** * Collection getter with filters populated for testLogoutOtherUserSessions() method * * @param AdminSessionInfo $session * @return ResourceModel\AdminSessionInfo\Collection */ protected function getCollectionForLogoutOtherUserSessions(\Magento\Security\Model\AdminSessionInfo $session) { /** @var \Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection $collection */ $collection = $session->getResourceCollection(); $collection->filterByUser($this->authSession->getUser()->getId(), \Magento\Security\Model\AdminSessionInfo::LOGGED_IN, $this->authSession->getSessionId())->filterExpiredSessions(100)->load(); return $collection; }
/** * {@inheritdoc} */ public function getSessionId() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getSessionId'); if (!$pluginInfo) { return parent::getSessionId(); } else { return $this->___callPlugins('getSessionId', func_get_args(), $pluginInfo); } }
/** * Create new record * * @return $this */ protected function createNewSession() { $this->adminSessionInfoFactory->create()->setData(['session_id' => $this->authSession->getSessionId(), 'user_id' => $this->authSession->getUser()->getId(), 'ip' => $this->remoteAddress->getRemoteAddress(), 'status' => AdminSessionInfo::LOGGED_IN])->save(); return $this; }