diff --git a/Observer/BackendAuthUserLoginSuccess.php b/Observer/BackendAuthUserLoginSuccess.php index 6080957..9b7b767 100644 --- a/Observer/BackendAuthUserLoginSuccess.php +++ b/Observer/BackendAuthUserLoginSuccess.php @@ -22,6 +22,7 @@ use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; +use MSP\TwoFactorAuth\Api\TfaInterface; use MSP\TwoFactorAuth\Api\TrustedManagerInterface; class BackendAuthUserLoginSuccess implements ObserverInterface @@ -31,10 +32,17 @@ class BackendAuthUserLoginSuccess implements ObserverInterface */ private $trustedManager; + /** + * @var TfaInterface + */ + private $tfa; + public function __construct( + TfaInterface $tfa, TrustedManagerInterface $trustedManager ) { $this->trustedManager = $trustedManager; + $this->tfa = $tfa; } /** @@ -43,6 +51,10 @@ public function __construct( */ public function execute(Observer $observer) { + if (!$this->tfa->getIsEnabled()) { + return; + } + if ($this->trustedManager->isTrustedDevice()) { $this->trustedManager->rotateTrustedDeviceToken(); } diff --git a/Observer/ControllerActionPredispatch.php b/Observer/ControllerActionPredispatch.php index 218f092..020b247 100644 --- a/Observer/ControllerActionPredispatch.php +++ b/Observer/ControllerActionPredispatch.php @@ -93,6 +93,10 @@ protected function getUser() */ public function execute(Observer $observer) { + if (!$this->tfa->getIsEnabled()) { + return; + } + /** @var $controllerAction \Magento\Backend\App\AbstractAction */ $controllerAction = $observer->getEvent()->getControllerAction(); $fullActionName = $controllerAction->getRequest()->getFullActionName(); diff --git a/etc/module.xml b/etc/module.xml index cda23d0..625ec39 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -21,7 +21,7 @@ --> - +