2222use Magento \TwoFactorAuth \Api \UserConfigRequestManagerInterface ;
2323use Magento \TwoFactorAuth \Controller \Adminhtml \Tfa \Requestconfig ;
2424use Magento \TwoFactorAuth \Model \UserConfig \HtmlAreaTokenVerifier ;
25+ use Magento \AdminAdobeIms \Service \ImsConfig ;
2526
2627/**
2728 * Handle redirection to 2FA page if required
@@ -75,6 +76,11 @@ class ControllerActionPredispatch implements ObserverInterface
7576 */
7677 private $ userContext ;
7778
79+ /**
80+ * @var ImsConfig
81+ */
82+ private ImsConfig $ adminAdobeImsConfig ;
83+
7884 /**
7985 * @param TfaInterface $tfa
8086 * @param TfaSessionInterface $tfaSession
@@ -84,6 +90,7 @@ class ControllerActionPredispatch implements ObserverInterface
8490 * @param UrlInterface $url
8591 * @param AuthorizationInterface $authorization
8692 * @param UserContextInterface $userContext
93+ * @param ImsConfig $adminAdobeImsConfig
8794 */
8895 public function __construct (
8996 TfaInterface $ tfa ,
@@ -93,7 +100,8 @@ public function __construct(
93100 ActionFlag $ actionFlag ,
94101 UrlInterface $ url ,
95102 AuthorizationInterface $ authorization ,
96- UserContextInterface $ userContext
103+ UserContextInterface $ userContext ,
104+ ImsConfig $ adminAdobeImsConfig
97105 ) {
98106 $ this ->tfa = $ tfa ;
99107 $ this ->tfaSession = $ tfaSession ;
@@ -103,6 +111,7 @@ public function __construct(
103111 $ this ->url = $ url ;
104112 $ this ->authorization = $ authorization ;
105113 $ this ->userContext = $ userContext ;
114+ $ this ->adminAdobeImsConfig = $ adminAdobeImsConfig ;
106115 }
107116
108117 /**
@@ -119,9 +128,13 @@ private function redirect(string $url): void
119128
120129 /**
121130 * @inheritDoc
131+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
122132 */
123133 public function execute (Observer $ observer )
124134 {
135+ if ($ this ->adminAdobeImsConfig ->enabled ()) {
136+ return ;
137+ }
125138 /** @var $controllerAction AbstractAction */
126139 $ controllerAction = $ observer ->getEvent ()->getData ('controller_action ' );
127140 $ this ->action = $ controllerAction ;
0 commit comments