1111use Magento \Backend \App \AbstractAction ;
1212use Magento \Framework \App \Action \Action ;
1313use Magento \Framework \App \ActionFlag ;
14+ use Magento \Framework \App \Config \ScopeConfigInterface ;
1415use Magento \Framework \AuthorizationInterface ;
1516use Magento \Framework \Event \Observer ;
1617use Magento \Framework \Event \ObserverInterface ;
18+ use Magento \Framework \Module \Manager as ModuleManager ;
1719use Magento \Framework \UrlInterface ;
1820use Magento \TwoFactorAuth \Controller \Adminhtml \Tfa \Configure ;
1921use Magento \TwoFactorAuth \Controller \Adminhtml \Tfa \Index ;
@@ -74,6 +76,14 @@ class ControllerActionPredispatch implements ObserverInterface
7476 * @var UserContextInterface
7577 */
7678 private $ userContext ;
79+ /**
80+ * @var ModuleManager
81+ */
82+ private $ moduleManager ;
83+ /**
84+ * @var ScopeConfigInterface
85+ */
86+ private $ scopeConfig ;
7787
7888 /**
7989 * @param TfaInterface $tfa
@@ -84,6 +94,8 @@ class ControllerActionPredispatch implements ObserverInterface
8494 * @param UrlInterface $url
8595 * @param AuthorizationInterface $authorization
8696 * @param UserContextInterface $userContext
97+ * @param ModuleManager $moduleManager
98+ * @param ScopeConfigInterface $scopeConfig
8799 */
88100 public function __construct (
89101 TfaInterface $ tfa ,
@@ -93,7 +105,9 @@ public function __construct(
93105 ActionFlag $ actionFlag ,
94106 UrlInterface $ url ,
95107 AuthorizationInterface $ authorization ,
96- UserContextInterface $ userContext
108+ UserContextInterface $ userContext ,
109+ ModuleManager $ moduleManager ,
110+ ScopeConfigInterface $ scopeConfig
97111 ) {
98112 $ this ->tfa = $ tfa ;
99113 $ this ->tfaSession = $ tfaSession ;
@@ -103,6 +117,8 @@ public function __construct(
103117 $ this ->url = $ url ;
104118 $ this ->authorization = $ authorization ;
105119 $ this ->userContext = $ userContext ;
120+ $ this ->moduleManager = $ moduleManager ;
121+ $ this ->scopeConfig = $ scopeConfig ;
106122 }
107123
108124 /**
@@ -122,6 +138,10 @@ private function redirect(string $url): void
122138 */
123139 public function execute (Observer $ observer )
124140 {
141+ if ($ this ->moduleManager ->isEnabled ('Magento_AdminAdobeIms ' )
142+ && !$ this ->scopeConfig ->isSetFlag ('adobe_ims/integration/two_factor ' )) {
143+ return ;
144+ }
125145 /** @var $controllerAction AbstractAction */
126146 $ controllerAction = $ observer ->getEvent ()->getData ('controller_action ' );
127147 $ this ->action = $ controllerAction ;
0 commit comments