Skip to content

Commit afd4197

Browse files
dmannersSebastianKull
authored andcommitted
CABPI-227: remove password fields
- add new after plugin - remove fields for password and confirmation
1 parent a7abf61 commit afd4197

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

app/code/Magento/AdminAdobeIms/Plugin/RemoveCurrentUserVerificationFieldsPlugin.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\AdminAdobeIms\Service\ImsConfig;
1212
use Magento\Framework\Data\Form;
1313
use Magento\Framework\Data\Form\Element\AbstractElement;
14-
use Magento\Backend\Block\System\Account\Edit\Form as VerificationForm;
1514

1615
class RemoveCurrentUserVerificationFieldsPlugin
1716
{
@@ -39,10 +38,7 @@ public function aroundAddElement(Form $subject, callable $proceed, AbstractEleme
3938
return $proceed($element, $after);
4039
}
4140

42-
if (
43-
$element->getId() !== 'current_user_verification_fieldset'
44-
&& $element->getId() !== VerificationForm::IDENTITY_VERIFICATION_PASSWORD_FIELD
45-
) {
41+
if ($element->getId() !== 'current_user_verification_fieldset') {
4642
return $proceed($element, $after);
4743
}
4844
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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\Framework\Data\Form\Element\AbstractElement;
13+
use Magento\Framework\Data\Form\Element\Fieldset;
14+
15+
class RemovePasswordFieldsPlugin
16+
{
17+
/** @var ImsConfig */
18+
private ImsConfig $imsConfig;
19+
20+
/**
21+
* @param ImsConfig $imsConfig
22+
*/
23+
public function __construct(
24+
ImsConfig $imsConfig
25+
) {
26+
$this->imsConfig = $imsConfig;
27+
}
28+
29+
/**
30+
* @param Fieldset $subject
31+
* @param AbstractElement $result
32+
* @param string $elementId
33+
* @param string $type
34+
* @param array $config
35+
* @param bool $after
36+
* @param bool $isAdvanced
37+
* @return AbstractElement
38+
*/
39+
public function afterAddField(
40+
Fieldset $subject,
41+
AbstractElement $result,
42+
$elementId,
43+
$type,
44+
$config,
45+
$after = false,
46+
$isAdvanced = false
47+
): AbstractElement
48+
{
49+
if ($this->imsConfig->enabled() !== true) {
50+
return $result;
51+
}
52+
53+
if (
54+
$subject->getId() === 'base_fieldset'
55+
&& (
56+
$elementId === 'password'
57+
|| $elementId === 'confirmation'
58+
)
59+
) {
60+
$subject->removeField($elementId);
61+
}
62+
return $result;
63+
}
64+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@
3434
<plugin name="aroundAddElement"
3535
type="Magento\AdminAdobeIms\Plugin\RemoveCurrentUserVerificationFieldsPlugin"/>
3636
</type>
37+
<type name="Magento\Framework\Data\Form\Element\Fieldset">
38+
<plugin name="afterAddField"
39+
type="Magento\AdminAdobeIms\Plugin\RemovePasswordFieldsPlugin"/>
40+
</type>
3741
</config>

0 commit comments

Comments
 (0)