Skip to content

Commit 6e7f8f6

Browse files
committed
AC-2653: Fix an admin custom URL functionality
1 parent c2f96a1 commit 6e7f8f6

File tree

2 files changed

+65
-56
lines changed

2 files changed

+65
-56
lines changed

app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,46 @@
1717
*/
1818
class Custom extends \Magento\Framework\App\Config\Value
1919
{
20-
const CONFIG_SCOPE = 'stores';
20+
public const CONFIG_SCOPE = 'stores';
2121

22-
const CONFIG_SCOPE_ID = 0;
22+
public const CONFIG_SCOPE_ID = 0;
2323

24-
const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
25-
const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
26-
const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url';
27-
const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url';
28-
const XML_PATH_CURRENCY_OPTIONS_BASE = 'currency/options/base';
29-
const XML_PATH_ADMIN_SECURITY_USEFORMKEY = 'admin/security/use_form_key';
30-
const XML_PATH_MAINTENANCE_MODE = 'maintenance_mode';
31-
const XML_PATH_WEB_COOKIE_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
24+
public const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
25+
public const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
26+
public const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url';
27+
public const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url';
28+
public const XML_PATH_CURRENCY_OPTIONS_BASE = 'currency/options/base';
29+
public const XML_PATH_ADMIN_SECURITY_USEFORMKEY = 'admin/security/use_form_key';
30+
public const XML_PATH_MAINTENANCE_MODE = 'maintenance_mode';
31+
public const XML_PATH_WEB_COOKIE_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
3232
/**
3333
* @deprecated Misspelled constant - use XML_PATH_WEB_COOKIE_COOKIE_PATH instead
3434
*/
35-
const XML_PATH_WEB_COOKIE_COOKE_PATH = 'web/cookie/cookie_path';
36-
const XML_PATH_WEB_COOKIE_COOKIE_PATH = 'web/cookie/cookie_path';
37-
const XML_PATH_WEB_COOKIE_COOKIE_DOMAIN = 'web/cookie/cookie_domain';
38-
const XML_PATH_WEB_COOKIE_HTTPONLY = 'web/cookie/cookie_httponly';
39-
const XML_PATH_WEB_COOKIE_RESTRICTION = 'web/cookie/cookie_restriction';
40-
const XML_PATH_GENERAL_LOCALE_TIMEZONE = 'general/locale/timezone';
41-
const XML_PATH_GENERAL_LOCALE_CODE = 'general/locale/code';
42-
const XML_PATH_GENERAL_COUNTRY_DEFAULT = 'general/country/default';
43-
const XML_PATH_SYSTEM_BACKUP_ENABLED = 'system/backup/enabled';
44-
const XML_PATH_DEV_JS_MERGE_FILES = 'dev/js/merge_files';
45-
const XML_PATH_DEV_JS_MINIFY_FILES = 'dev/js/minify_files';
46-
const XML_PATH_DEV_CSS_MERGE_CSS_FILES = 'dev/css/merge_css_files';
47-
const XML_PATH_DEV_CSS_MINIFY_FILES = 'dev/css/minify_files';
48-
const XML_PATH_DEV_IMAGE_DEFAULT_ADAPTER = 'dev/image/default_adapter';
49-
const XML_PATH_WEB_SESSION_USE_FRONTEND_SID = 'web/session/use_frontend_sid';
50-
const XML_PATH_WEB_SESSION_USE_HTTP_X_FORWARDED_FOR = 'web/session/use_http_x_forwarded_for';
51-
const XML_PATH_WEB_SESSION_USE_HTTP_VIA = 'web/session/use_http_via';
52-
const XML_PATH_WEB_SESSION_USE_REMOTE_ADDR = 'web/session/use_remote_addr';
53-
const XML_PATH_WEB_SESSION_USE_HTTP_USER_AGENT = 'web/session/use_http_user_agent';
54-
const XML_PATH_CATALOG_FRONTEND_FLAT_CATALOG_CATEGORY = 'catalog/frontend/flat_catalog_category';
55-
const XML_PATH_CATALOG_FRONTEND_FLAT_CATALOG_PRODUCT = 'catalog/frontend/flat_catalog_product';
56-
const XML_PATH_TAX_WEEE_ENABLE = 'tax/weee/enable';
57-
const XML_PATH_CATALOG_SEARCH_ENGINE = 'catalog/search/engine';
58-
const XML_PATH_CARRIERS = 'carriers';
59-
const XML_PATH_PAYMENT = 'payment';
35+
public const XML_PATH_WEB_COOKIE_COOKE_PATH = 'web/cookie/cookie_path';
36+
public const XML_PATH_WEB_COOKIE_COOKIE_PATH = 'web/cookie/cookie_path';
37+
public const XML_PATH_WEB_COOKIE_COOKIE_DOMAIN = 'web/cookie/cookie_domain';
38+
public const XML_PATH_WEB_COOKIE_HTTPONLY = 'web/cookie/cookie_httponly';
39+
public const XML_PATH_WEB_COOKIE_RESTRICTION = 'web/cookie/cookie_restriction';
40+
public const XML_PATH_GENERAL_LOCALE_TIMEZONE = 'general/locale/timezone';
41+
public const XML_PATH_GENERAL_LOCALE_CODE = 'general/locale/code';
42+
public const XML_PATH_GENERAL_COUNTRY_DEFAULT = 'general/country/default';
43+
public const XML_PATH_SYSTEM_BACKUP_ENABLED = 'system/backup/enabled';
44+
public const XML_PATH_DEV_JS_MERGE_FILES = 'dev/js/merge_files';
45+
public const XML_PATH_DEV_JS_MINIFY_FILES = 'dev/js/minify_files';
46+
public const XML_PATH_DEV_CSS_MERGE_CSS_FILES = 'dev/css/merge_css_files';
47+
public const XML_PATH_DEV_CSS_MINIFY_FILES = 'dev/css/minify_files';
48+
public const XML_PATH_DEV_IMAGE_DEFAULT_ADAPTER = 'dev/image/default_adapter';
49+
public const XML_PATH_WEB_SESSION_USE_FRONTEND_SID = 'web/session/use_frontend_sid';
50+
public const XML_PATH_WEB_SESSION_USE_HTTP_X_FORWARDED_FOR = 'web/session/use_http_x_forwarded_for';
51+
public const XML_PATH_WEB_SESSION_USE_HTTP_VIA = 'web/session/use_http_via';
52+
public const XML_PATH_WEB_SESSION_USE_REMOTE_ADDR = 'web/session/use_remote_addr';
53+
public const XML_PATH_WEB_SESSION_USE_HTTP_USER_AGENT = 'web/session/use_http_user_agent';
54+
public const XML_PATH_CATALOG_FRONTEND_FLAT_CATALOG_CATEGORY = 'catalog/frontend/flat_catalog_category';
55+
public const XML_PATH_CATALOG_FRONTEND_FLAT_CATALOG_PRODUCT = 'catalog/frontend/flat_catalog_product';
56+
public const XML_PATH_TAX_WEEE_ENABLE = 'tax/weee/enable';
57+
public const XML_PATH_CATALOG_SEARCH_ENGINE = 'catalog/search/engine';
58+
public const XML_PATH_CARRIERS = 'carriers';
59+
public const XML_PATH_PAYMENT = 'payment';
6060

6161
/**
6262
* @var \Magento\Framework\App\Config\Storage\WriterInterface

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

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
namespace Magento\Security\Model;
99

1010
use Exception;
11+
use Magento\Backend\Model\Auth\Session;
1112
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
14+
use Magento\Framework\Stdlib\DateTime\DateTime;
15+
use Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection;
1316
use Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory;
1417

1518
/**
@@ -23,12 +26,12 @@ class AdminSessionsManager
2326
/**
2427
* Admin Session lifetime (sec)
2528
*/
26-
const ADMIN_SESSION_LIFETIME = 86400;
29+
public const ADMIN_SESSION_LIFETIME = 86400;
2730

2831
/**
2932
* Logout reason when current user has been locked out
3033
*/
31-
const LOGOUT_REASON_USER_LOCKED = 10;
34+
public const LOGOUT_REASON_USER_LOCKED = 10;
3235

3336
/**
3437
* @var ConfigInterface
@@ -37,7 +40,7 @@ class AdminSessionsManager
3740
protected $securityConfig;
3841

3942
/**
40-
* @var \Magento\Backend\Model\Auth\Session
43+
* @var Session
4144
* @since 100.1.0
4245
*/
4346
protected $authSession;
@@ -49,19 +52,19 @@ class AdminSessionsManager
4952
protected $adminSessionInfoFactory;
5053

5154
/**
52-
* @var \Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory
55+
* @var CollectionFactory
5356
* @since 100.1.0
5457
*/
5558
protected $adminSessionInfoCollectionFactory;
5659

5760
/**
58-
* @var \Magento\Security\Model\AdminSessionInfo
61+
* @var AdminSessionInfo
5962
* @since 100.1.0
6063
*/
6164
protected $currentSession;
6265

6366
/**
64-
* @var \Magento\Framework\Stdlib\DateTime\DateTime
67+
* @var DateTime
6568
*/
6669
private $dateTime;
6770

@@ -75,23 +78,25 @@ class AdminSessionsManager
7578
*
7679
* Means that after session was prolonged
7780
* all other prolongs will be ignored within this period
81+
*
82+
* @var int
7883
*/
7984
private $maxIntervalBetweenConsecutiveProlongs = 60;
8085

8186
/**
8287
* @param ConfigInterface $securityConfig
83-
* @param \Magento\Backend\Model\Auth\Session $authSession
88+
* @param Session $authSession
8489
* @param AdminSessionInfoFactory $adminSessionInfoFactory
8590
* @param CollectionFactory $adminSessionInfoCollectionFactory
86-
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
91+
* @param DateTime $dateTime
8792
* @param RemoteAddress $remoteAddress
8893
*/
8994
public function __construct(
9095
ConfigInterface $securityConfig,
91-
\Magento\Backend\Model\Auth\Session $authSession,
92-
\Magento\Security\Model\AdminSessionInfoFactory $adminSessionInfoFactory,
93-
\Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory $adminSessionInfoCollectionFactory,
94-
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
96+
Session $authSession,
97+
AdminSessionInfoFactory $adminSessionInfoFactory,
98+
CollectionFactory $adminSessionInfoCollectionFactory,
99+
DateTime $dateTime,
95100
RemoteAddress $remoteAddress
96101
) {
97102
$this->securityConfig = $securityConfig;
@@ -106,6 +111,7 @@ public function __construct(
106111
* Handle all others active sessions according Sharing Account Setting
107112
*
108113
* @return $this
114+
* @throws Exception
109115
* @since 100.1.0
110116
*/
111117
public function processLogin()
@@ -132,6 +138,7 @@ public function processLogin()
132138
* Handle Prolong process
133139
*
134140
* @return $this
141+
* @throws Exception
135142
* @since 100.1.0
136143
*/
137144
public function processProlong()
@@ -172,6 +179,7 @@ public function processLogout()
172179
* Get current session record
173180
*
174181
* @return AdminSessionInfo
182+
* @throws Exception
175183
* @since 100.1.0
176184
*/
177185
public function getCurrentSession()
@@ -244,13 +252,13 @@ public function getLogoutReasonMessage()
244252
/**
245253
* Get sessions for current user
246254
*
247-
* @return \Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection
255+
* @return Collection
248256
* @since 100.1.0
249257
*/
250258
public function getSessionsForCurrentUser()
251259
{
252260
return $this->createAdminSessionInfoCollection()
253-
->filterByUser($this->authSession->getUser()->getId(), \Magento\Security\Model\AdminSessionInfo::LOGGED_IN)
261+
->filterByUser($this->authSession->getUser()->getId(), AdminSessionInfo::LOGGED_IN)
254262
->filterExpiredSessions($this->securityConfig->getAdminSessionLifetime())
255263
->loadData();
256264
}
@@ -266,13 +274,13 @@ public function logoutOtherUserSessions()
266274
$collection = $this->createAdminSessionInfoCollection()
267275
->filterByUser(
268276
$this->authSession->getUser()->getId(),
269-
\Magento\Security\Model\AdminSessionInfo::LOGGED_IN,
277+
AdminSessionInfo::LOGGED_IN,
270278
$this->authSession->getAdminSessionInfoId()
271279
)
272280
->filterExpiredSessions($this->securityConfig->getAdminSessionLifetime())
273281
->loadData();
274282

275-
$collection->setDataToAll('status', \Magento\Security\Model\AdminSessionInfo::LOGGED_OUT_MANUALLY)
283+
$collection->setDataToAll('status', AdminSessionInfo::LOGGED_OUT_MANUALLY)
276284
->save();
277285

278286
return $this;
@@ -304,8 +312,8 @@ protected function createNewSession()
304312
{
305313
$user = $this->authSession->getUser();
306314
if (null === $user) {
307-
$this->processLogout();
308-
throw new LocalizedException(__('User not found'));
315+
$this->processLogout();
316+
throw new LocalizedException(__('User not found'));
309317
}
310318

311319
$adminSessionInfo = $this->adminSessionInfoFactory
@@ -324,7 +332,9 @@ protected function createNewSession()
324332
}
325333

326334
/**
327-
* @return \Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection
335+
* Creates the collection of admin session
336+
*
337+
* @return Collection
328338
* @since 100.1.0
329339
*/
330340
protected function createAdminSessionInfoCollection()
@@ -333,8 +343,7 @@ protected function createAdminSessionInfoCollection()
333343
}
334344

335345
/**
336-
* Calculates diff between now and last session updated_at
337-
* and decides whether new prolong must be triggered or not
346+
* Calculates diff between now and last session updated_at and decides whether new prolong must be triggered or not
338347
*
339348
* This is done to limit amount of session prolongs and updates to database
340349
* within some period of time - X

0 commit comments

Comments
 (0)