Skip to content

Commit 9395e68

Browse files
committed
AC-2653: Fix an admin custom URL functionality
1 parent f605b71 commit 9395e68

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,16 @@ public function afterSave()
119119
}
120120

121121
if ($useCustomUrl == 1) {
122-
$this->_configWriter->save(
122+
$paths = [
123123
self::XML_PATH_SECURE_BASE_URL,
124-
$value,
125-
self::CONFIG_SCOPE,
126-
self::CONFIG_SCOPE_ID
127-
);
128-
$this->_configWriter->save(
129124
self::XML_PATH_UNSECURE_BASE_URL,
130-
$value,
131-
self::CONFIG_SCOPE,
132-
self::CONFIG_SCOPE_ID
133-
);
125+
self::XML_PATH_SECURE_BASE_LINK_URL,
126+
self::XML_PATH_UNSECURE_BASE_LINK_URL,
127+
];
128+
129+
foreach ($paths as $path) {
130+
$this->_configWriter->save($path, $value, self::CONFIG_SCOPE, self::CONFIG_SCOPE_ID);
131+
}
134132
}
135133

136134
return parent::afterSave();

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ public function afterSave()
7878
$value = $this->getValue();
7979

8080
if (!$value) {
81-
$this->_configWriter->delete(
81+
$paths = [
8282
Custom::XML_PATH_SECURE_BASE_URL,
83-
Custom::CONFIG_SCOPE,
84-
Custom::CONFIG_SCOPE_ID
85-
);
86-
$this->_configWriter->delete(
8783
Custom::XML_PATH_UNSECURE_BASE_URL,
88-
Custom::CONFIG_SCOPE,
89-
Custom::CONFIG_SCOPE_ID
90-
);
84+
Custom::XML_PATH_SECURE_BASE_LINK_URL,
85+
Custom::XML_PATH_UNSECURE_BASE_LINK_URL,
86+
];
87+
88+
foreach ($paths as $path) {
89+
$this->_configWriter->delete($path, Custom::CONFIG_SCOPE, Custom::CONFIG_SCOPE_ID);
90+
}
9191
}
9292

9393
return parent::afterSave();

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\Security\Model;
99

10+
use Exception;
11+
use Magento\Framework\Exception\LocalizedException;
1012
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
1113
use Magento\Security\Model\ResourceModel\AdminSessionInfo\CollectionFactory;
1214

@@ -152,6 +154,7 @@ public function processProlong()
152154
* Handle logout process
153155
*
154156
* @return $this
157+
* @throws Exception
155158
* @since 100.1.0
156159
*/
157160
public function processLogout()
@@ -294,15 +297,22 @@ public function cleanExpiredSessions()
294297
* Create new record
295298
*
296299
* @return $this
300+
* @throws Exception
297301
* @since 100.1.0
298302
*/
299303
protected function createNewSession()
300304
{
305+
$user = $this->authSession->getUser();
306+
if (null === $user) {
307+
$this->processLogout();
308+
throw new LocalizedException(__('User is not found'));
309+
}
310+
301311
$adminSessionInfo = $this->adminSessionInfoFactory
302312
->create()
303313
->setData(
304314
[
305-
'user_id' => $this->authSession->getUser()->getId(),
315+
'user_id' => $user->getId(),
306316
'ip' => $this->remoteAddress->getRemoteAddress(),
307317
'status' => AdminSessionInfo::LOGGED_IN
308318
]

0 commit comments

Comments
 (0)