File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
app/code/Magento/Security
dev/tests/integration/testsuite/Magento/Backend/Model/Auth Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 88namespace Magento \Security \Model ;
99
1010use Magento \Framework \HTTP \PhpEnvironment \RemoteAddress ;
11- use \ Magento \Security \Model \ResourceModel \AdminSessionInfo \CollectionFactory ;
11+ use Magento \Security \Model \ResourceModel \AdminSessionInfo \CollectionFactory ;
1212
1313/**
1414 * Admin Sessions Manager Model
@@ -174,8 +174,15 @@ public function processLogout()
174174 public function getCurrentSession ()
175175 {
176176 if (!$ this ->currentSession ) {
177+ $ adminSessionInfoId = $ this ->authSession ->getAdminSessionInfoId ();
178+ if (!$ adminSessionInfoId ) {
179+ $ this ->createNewSession ();
180+ $ adminSessionInfoId = $ this ->authSession ->getAdminSessionInfoId ();
181+ $ this ->logoutOtherUserSessions ();
182+ }
183+
177184 $ this ->currentSession = $ this ->adminSessionInfoFactory ->create ();
178- $ this ->currentSession ->load ($ this -> authSession -> getAdminSessionInfoId () , 'id ' );
185+ $ this ->currentSession ->load ($ adminSessionInfoId , 'id ' );
179186 }
180187
181188 return $ this ->currentSession ;
Original file line number Diff line number Diff line change @@ -335,9 +335,32 @@ public function testCleanExpiredSessions()
335335 */
336336 public function testGetLogoutReasonMessage ($ expectedResult , $ sessionStatus )
337337 {
338- $ this ->adminSessionInfoFactoryMock ->expects ($ this ->once ( ))
338+ $ this ->adminSessionInfoFactoryMock ->expects ($ this ->exactly ( 2 ))
339339 ->method ('create ' )
340340 ->willReturn ($ this ->currentSessionMock );
341+ $ this ->authSessionMock ->expects ($ this ->any ())
342+ ->method ('getUser ' )
343+ ->willReturn ($ this ->userMock );
344+ $ this ->currentSessionMock ->expects ($ this ->once ())
345+ ->method ('setData ' )
346+ ->willReturn ($ this ->currentSessionMock );
347+ $ this ->currentSessionMock ->expects ($ this ->once ())
348+ ->method ('save ' )
349+ ->willReturn ($ this ->currentSessionMock );
350+ $ this ->adminSessionInfoCollectionFactoryMock ->expects ($ this ->once ())
351+ ->method ('create ' )
352+ ->willReturn ($ this ->adminSessionInfoCollectionMock );
353+ $ this ->adminSessionInfoCollectionMock ->expects ($ this ->once ())->method ('filterByUser ' )
354+ ->willReturnSelf ();
355+ $ this ->adminSessionInfoCollectionMock ->expects ($ this ->once ())
356+ ->method ('filterExpiredSessions ' )
357+ ->willReturnSelf ();
358+ $ this ->adminSessionInfoCollectionMock ->expects ($ this ->once ())
359+ ->method ('loadData ' )
360+ ->willReturnSelf ();
361+ $ this ->adminSessionInfoCollectionMock ->expects ($ this ->once ())
362+ ->method ('setDataToAll ' )
363+ ->willReturnSelf ();
341364 $ this ->currentSessionMock ->expects ($ this ->once ())
342365 ->method ('getStatus ' )
343366 ->willReturn ($ sessionStatus );
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ protected function setUp(): void
3939 ->setCurrentScope (\Magento \Backend \App \Area \FrontNameResolver::AREA_CODE );
4040 $ this ->auth = $ this ->objectManager ->create (\Magento \Backend \Model \Auth::class);
4141 $ this ->authSession = $ this ->objectManager ->create (\Magento \Backend \Model \Auth \Session::class);
42+ $ this ->authSession ->setUser ($ this ->objectManager ->create (\Magento \User \Model \User::class));
4243 $ this ->auth ->setAuthStorage ($ this ->authSession );
4344 $ this ->auth ->logout ();
4445 }
You can’t perform that action at this time.
0 commit comments