Skip to content

Commit 1bf4b00

Browse files
committed
Merge branch 'ims-phase1' of github.com:magento-performance/magento2ce into CABPI-324
2 parents 1281933 + 523fceb commit 1bf4b00

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

app/code/Magento/Security/Model/AdminSessionsManager.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,20 @@ public function getSessionsForCurrentUser()
266266
*/
267267
public function logoutOtherUserSessions()
268268
{
269-
$collection = $this->createAdminSessionInfoCollection()
270-
->filterByUser(
271-
$this->authSession->getUser()->getId(),
272-
\Magento\Security\Model\AdminSessionInfo::LOGGED_IN,
273-
$this->authSession->getAdminSessionInfoId()
274-
)
275-
->filterExpiredSessions($this->securityConfig->getAdminSessionLifetime())
276-
->loadData();
269+
$user = $this->authSession->getUser();
270+
if ($user) {
271+
$collection = $this->createAdminSessionInfoCollection()
272+
->filterByUser(
273+
$user->getId(),
274+
\Magento\Security\Model\AdminSessionInfo::LOGGED_IN,
275+
$this->authSession->getAdminSessionInfoId()
276+
)
277+
->filterExpiredSessions($this->securityConfig->getAdminSessionLifetime())
278+
->loadData();
277279

278-
$collection->setDataToAll('status', \Magento\Security\Model\AdminSessionInfo::LOGGED_OUT_MANUALLY)
279-
->save();
280+
$collection->setDataToAll('status', \Magento\Security\Model\AdminSessionInfo::LOGGED_OUT_MANUALLY)
281+
->save();
282+
}
280283

281284
return $this;
282285
}
@@ -304,11 +307,12 @@ public function cleanExpiredSessions()
304307
*/
305308
protected function createNewSession()
306309
{
310+
$user = $this->authSession->getUser();
307311
$adminSessionInfo = $this->adminSessionInfoFactory
308312
->create()
309313
->setData(
310314
[
311-
'user_id' => $this->authSession->getUser()->getId(),
315+
'user_id' => $user ? $user->getId() : null,
312316
'ip' => $this->remoteAddress->getRemoteAddress(),
313317
'status' => AdminSessionInfo::LOGGED_IN
314318
]

0 commit comments

Comments
 (0)