7
7
8
8
namespace Magento \Security \Model ;
9
9
10
+ use Magento \Backend \Model \Auth \Session ;
10
11
use Magento \Framework \HTTP \PhpEnvironment \RemoteAddress ;
12
+ use Magento \Framework \Stdlib \DateTime ;
13
+ use Magento \Security \Model \ResourceModel \AdminSessionInfo \Collection ;
11
14
use Magento \Security \Model \ResourceModel \AdminSessionInfo \CollectionFactory ;
12
15
13
16
/**
@@ -35,7 +38,7 @@ class AdminSessionsManager
35
38
protected $ securityConfig ;
36
39
37
40
/**
38
- * @var \Magento\Backend\Model\Auth\ Session
41
+ * @var Session
39
42
* @since 100.1.0
40
43
*/
41
44
protected $ authSession ;
@@ -73,20 +76,22 @@ class AdminSessionsManager
73
76
*
74
77
* Means that after session was prolonged
75
78
* all other prolongs will be ignored within this period
79
+ *
80
+ * @var int
76
81
*/
77
82
private $ maxIntervalBetweenConsecutiveProlongs = 60 ;
78
83
79
84
/**
80
85
* @param ConfigInterface $securityConfig
81
- * @param \Magento\Backend\Model\Auth\ Session $authSession
86
+ * @param Session $authSession
82
87
* @param AdminSessionInfoFactory $adminSessionInfoFactory
83
88
* @param CollectionFactory $adminSessionInfoCollectionFactory
84
89
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
85
90
* @param RemoteAddress $remoteAddress
86
91
*/
87
92
public function __construct (
88
93
ConfigInterface $ securityConfig ,
89
- \ Magento \ Backend \ Model \ Auth \ Session $ authSession ,
94
+ Session $ authSession ,
90
95
\Magento \Security \Model \AdminSessionInfoFactory $ adminSessionInfoFactory ,
91
96
\Magento \Security \Model \ResourceModel \AdminSessionInfo \CollectionFactory $ adminSessionInfoCollectionFactory ,
92
97
\Magento \Framework \Stdlib \DateTime \DateTime $ dateTime ,
@@ -138,7 +143,7 @@ public function processProlong()
138
143
$ this ->getCurrentSession ()->setData (
139
144
'updated_at ' ,
140
145
date (
141
- \ Magento \ Framework \ Stdlib \ DateTime::DATETIME_PHP_FORMAT ,
146
+ DateTime::DATETIME_PHP_FORMAT ,
142
147
$ this ->authSession ->getUpdatedAt ()
143
148
)
144
149
);
@@ -204,7 +209,7 @@ public function getLogoutReasonMessageByStatus($statusCode)
204
209
case AdminSessionInfo::LOGGED_OUT_BY_LOGIN :
205
210
$ reasonMessage = __ (
206
211
'Someone logged into this account from another device or browser. '
207
- .' Your current session is terminated. '
212
+ . ' Your current session is terminated. '
208
213
);
209
214
break ;
210
215
case AdminSessionInfo::LOGGED_OUT_MANUALLY :
@@ -241,7 +246,7 @@ public function getLogoutReasonMessage()
241
246
/**
242
247
* Get sessions for current user
243
248
*
244
- * @return \Magento\Security\Model\ResourceModel\AdminSessionInfo\ Collection
249
+ * @return Collection
245
250
* @since 100.1.0
246
251
*/
247
252
public function getSessionsForCurrentUser ()
@@ -314,7 +319,9 @@ protected function createNewSession()
314
319
}
315
320
316
321
/**
317
- * @return \Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection
322
+ * Retrieve new instance of admin session info collection
323
+ *
324
+ * @return Collection
318
325
* @since 100.1.0
319
326
*/
320
327
protected function createAdminSessionInfoCollection ()
@@ -323,15 +330,14 @@ protected function createAdminSessionInfoCollection()
323
330
}
324
331
325
332
/**
326
- * Calculates diff between now and last session updated_at
327
- * and decides whether new prolong must be triggered or not
333
+ * Calculates diff between now and last session updated_at and decides whether new prolong must be triggered or not
328
334
*
329
335
* This is done to limit amount of session prolongs and updates to database
330
336
* within some period of time - X
331
337
* X - is calculated in getIntervalBetweenConsecutiveProlongs()
332
338
*
333
- * @see getIntervalBetweenConsecutiveProlongs()
334
339
* @return bool
340
+ * @see getIntervalBetweenConsecutiveProlongs()
335
341
*/
336
342
private function lastProlongIsOldEnough ()
337
343
{
@@ -344,7 +350,7 @@ private function lastProlongIsOldEnough()
344
350
345
351
$ diff = $ nowTimestamp - $ lastProlongTimestamp ;
346
352
347
- return (float ) $ diff > $ this ->getIntervalBetweenConsecutiveProlongs ();
353
+ return (float )$ diff > $ this ->getIntervalBetweenConsecutiveProlongs ();
348
354
}
349
355
350
356
/**
@@ -358,7 +364,7 @@ private function lastProlongIsOldEnough()
358
364
*/
359
365
private function getIntervalBetweenConsecutiveProlongs ()
360
366
{
361
- return (float ) max (
367
+ return (float )max (
362
368
1 ,
363
369
min (
364
370
4 * log ((float )$ this ->securityConfig ->getAdminSessionLifetime ()),
0 commit comments