10 use \Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory;
68 private $remoteAddress;
76 private $maxIntervalBetweenConsecutiveProlongs = 60;
91 \
Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
99 $this->remoteAddress = $remoteAddress;
112 $olderThen = $this->dateTime->gmtTimestamp() - $this->securityConfig->getAdminSessionLifetime();
113 if (!$this->securityConfig->isAdminAccountSharingEnabled()) {
136 if ($this->lastProlongIsOldEnough()) {
140 \
Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT,
141 $this->authSession->getUpdatedAt()
175 if (!$this->currentSession) {
176 $this->currentSession = $this->adminSessionInfoFactory->create();
177 $this->currentSession->load($this->authSession->getSessionId(),
'session_id');
192 switch ((
int)$statusCode) {
194 $reasonMessage =
null;
198 'Someone logged into this account from another device or browser.' 199 .
' Your current session is terminated.' 204 'Your current session is terminated by another user of this account.' 209 'Your account is temporarily disabled. Please try again later.' 213 $reasonMessage =
__(
'Your current session has been expired.');
217 return $reasonMessage;
243 ->filterExpiredSessions($this->securityConfig->getAdminSessionLifetime())
257 $this->authSession->getUser()->getId(),
259 $this->authSession->getSessionId()
261 ->filterExpiredSessions($this->securityConfig->getAdminSessionLifetime())
293 $this->adminSessionInfoFactory
297 'session_id' => $this->authSession->getSessionId(),
298 'user_id' => $this->authSession->getUser()->getId(),
299 'ip' => $this->remoteAddress->getRemoteAddress(),
313 return $this->adminSessionInfoCollectionFactory->create();
327 private function lastProlongIsOldEnough()
330 $nowTimestamp = $this->authSession->getUpdatedAt();
332 $diff = $nowTimestamp - $lastProlongTimestamp;
334 return (
float) $diff > $this->getIntervalBetweenConsecutiveProlongs();
346 private function getIntervalBetweenConsecutiveProlongs()
351 4 * log((
float)$this->securityConfig->getAdminSessionLifetime()),
352 $this->maxIntervalBetweenConsecutiveProlongs
$adminSessionInfoCollectionFactory
logoutOtherUserSessions()
const ADMIN_SESSION_LIFETIME
getSessionsForCurrentUser()
createAdminSessionInfoCollection()
const LOGGED_OUT_MANUALLY
const LOGGED_OUT_BY_LOGIN
getLogoutReasonMessageByStatus($statusCode)
const LOGOUT_REASON_USER_LOCKED
__construct(ConfigInterface $securityConfig, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Security\Model\AdminSessionInfoFactory $adminSessionInfoFactory, \Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory $adminSessionInfoCollectionFactory, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, RemoteAddress $remoteAddress)