File tree 3 files changed +34
-3
lines changed
app/code/Magento/Security
dev/tests/integration/testsuite/Magento/Backend/Model/Auth
3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 8
8
namespace Magento \Security \Model ;
9
9
10
10
use Magento \Framework \HTTP \PhpEnvironment \RemoteAddress ;
11
- use \ Magento \Security \Model \ResourceModel \AdminSessionInfo \CollectionFactory ;
11
+ use Magento \Security \Model \ResourceModel \AdminSessionInfo \CollectionFactory ;
12
12
13
13
/**
14
14
* Admin Sessions Manager Model
@@ -174,8 +174,15 @@ public function processLogout()
174
174
public function getCurrentSession ()
175
175
{
176
176
if (!$ this ->currentSession ) {
177
+ $ adminSessionInfoId = $ this ->authSession ->getAdminSessionInfoId ();
178
+ if (!$ adminSessionInfoId ) {
179
+ $ this ->createNewSession ();
180
+ $ adminSessionInfoId = $ this ->authSession ->getAdminSessionInfoId ();
181
+ $ this ->logoutOtherUserSessions ();
182
+ }
183
+
177
184
$ this ->currentSession = $ this ->adminSessionInfoFactory ->create ();
178
- $ this ->currentSession ->load ($ this -> authSession -> getAdminSessionInfoId () , 'id ' );
185
+ $ this ->currentSession ->load ($ adminSessionInfoId , 'id ' );
179
186
}
180
187
181
188
return $ this ->currentSession ;
Original file line number Diff line number Diff line change @@ -335,9 +335,32 @@ public function testCleanExpiredSessions()
335
335
*/
336
336
public function testGetLogoutReasonMessage ($ expectedResult , $ sessionStatus )
337
337
{
338
- $ this ->adminSessionInfoFactoryMock ->expects ($ this ->once ( ))
338
+ $ this ->adminSessionInfoFactoryMock ->expects ($ this ->exactly ( 2 ))
339
339
->method ('create ' )
340
340
->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 ();
341
364
$ this ->currentSessionMock ->expects ($ this ->once ())
342
365
->method ('getStatus ' )
343
366
->willReturn ($ sessionStatus );
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ protected function setUp(): void
39
39
->setCurrentScope (\Magento \Backend \App \Area \FrontNameResolver::AREA_CODE );
40
40
$ this ->auth = $ this ->objectManager ->create (\Magento \Backend \Model \Auth::class);
41
41
$ this ->authSession = $ this ->objectManager ->create (\Magento \Backend \Model \Auth \Session::class);
42
+ $ this ->authSession ->setUser ($ this ->objectManager ->create (\Magento \User \Model \User::class));
42
43
$ this ->auth ->setAuthStorage ($ this ->authSession );
43
44
$ this ->auth ->logout ();
44
45
}
You can’t perform that action at this time.
0 commit comments