Skip to content

Commit c8562ef

Browse files
dmannersSebastianKull
authored andcommitted
CABPI-227: disable password reset and force change
- add plugin to return 0 as password lifetime thus disabling that, - return false for forced change config read
1 parent 058fa39 commit c8562ef

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdminAdobeIms\Plugin;
10+
11+
use Magento\AdminAdobeIms\Service\ImsConfig;
12+
use Magento\User\Model\Backend\Config\ObserverConfig;
13+
14+
class DisableForcedPasswordChangePlugin
15+
{
16+
/** @var ImsConfig */
17+
private ImsConfig $imsConfig;
18+
19+
/**
20+
* @param ImsConfig $imsConfig
21+
*/
22+
public function __construct(
23+
ImsConfig $imsConfig
24+
) {
25+
$this->imsConfig = $imsConfig;
26+
}
27+
28+
/**
29+
* Disable forced password change when our module is active
30+
*
31+
* @param ObserverConfig $subject
32+
* @param bool $result
33+
* @return bool
34+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
35+
*/
36+
public function afterIsPasswordChangeForced(ObserverConfig $subject, bool $result): bool
37+
{
38+
if ($this->imsConfig->enabled() === false) {
39+
return $result;
40+
}
41+
return false;
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdminAdobeIms\Plugin;
10+
11+
use Magento\AdminAdobeIms\Service\ImsConfig;
12+
use Magento\User\Model\Backend\Config\ObserverConfig;
13+
14+
class DisablePasswordResetPlugin
15+
{
16+
/** @var ImsConfig */
17+
private ImsConfig $imsConfig;
18+
19+
/**
20+
* @param ImsConfig $imsConfig
21+
*/
22+
public function __construct(
23+
ImsConfig $imsConfig
24+
) {
25+
$this->imsConfig = $imsConfig;
26+
}
27+
28+
/**
29+
* Since the password reset module treats 0 as disabled we can just return 0 when our module is enabled
30+
*
31+
* @param ObserverConfig $subject
32+
* @param float $result
33+
* @return float
34+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
35+
*/
36+
public function afterGetAdminPasswordLifetime(ObserverConfig $subject, float $result): float
37+
{
38+
if ($this->imsConfig->enabled() === false) {
39+
return $result;
40+
}
41+
return 0;
42+
}
43+
}

app/code/Magento/AdminAdobeIms/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,3 @@ Open:
134134
2. Validate that when disabled the fields work again,
135135
3. Update Wiki
136136
4. Functional tests
137-
5. Test user with no password, but module disable with POST Request and API call

app/code/Magento/AdminAdobeIms/etc/adminhtml/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@
5858
<plugin name="remove_user_validation_rules"
5959
type="Magento\AdminAdobeIms\Plugin\RemoveUserValidationRulesPlugin"/>
6060
</type>
61+
<type name="Magento\User\Model\Backend\Config\ObserverConfig">
62+
<plugin name="disable_password_reset"
63+
type="Magento\AdminAdobeIms\Plugin\DisablePasswordResetPlugin"/>
64+
<plugin name="disable_forced_password_change"
65+
type="Magento\AdminAdobeIms\Plugin\DisableForcedPasswordChangePlugin"/>
66+
</type>
6167
</config>

0 commit comments

Comments
 (0)