Skip to content

Commit 30846c9

Browse files
authored
Merge pull request #12 from YouweGit/feature/revert-changes
revert changes use only controller dispatch event obsever
2 parents 21d7605 + 20a9e90 commit 30846c9

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

Observer/TfaFrontendCheck.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
9494
return $this;
9595
}
9696
$this->logger->info('TfaFrontendCheck isLoggedIn true');
97-
if (in_array($this->request->getFullActionName(), $this->getAllowedRoutes($customer))) {
97+
if (in_array($observer->getEvent()->getRequest()->getFullActionName(), $this->getAllowedRoutes($customer))) {
9898
$this->logger->info('TfaFrontendCheck getAllowedRoutes true');
9999
return $this;
100100
}
@@ -108,20 +108,14 @@ public function execute(\Magento\Framework\Event\Observer $observer)
108108
// Redirect to 2FA authentication page
109109
$redirectionUrl = $this->url->getUrl(self::FRONTEND_2_FA_ACCOUNT_AUTHENTICATE_PATH);
110110
$this->logger->info('TfaFrontendCheck is2faConfiguredForCustomer redirect',[$redirectionUrl]);
111-
$this->redirect->setRedirect($redirectionUrl);
112-
113-
return;
111+
$observer->getControllerAction()->getResponse()->setRedirect($redirectionUrl);
114112
} elseif ($this->isCustomerInForced2faGroup($customer)) {
115113
// Redirect to 2FA setup page
116114
$this->messageManager->addNoticeMessage(__('You need to set up Two Factor Authentication before continuing.'));
117115
$redirectionUrl = $this->url->getUrl(self::FRONTEND_2_FA_ACCOUNT_SETUP_PATH);
118-
$this->redirect->setRedirect($redirectionUrl);
119-
120-
return;
116+
$observer->getControllerAction()->getResponse()->setRedirect($redirectionUrl);
121117
}
122118

123-
124-
125119
return $this;
126120
}
127121

etc/frontend/events.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@
77
<observer name="customer_2fa_check_logout"
88
instance="Elgentos\Frontend2FA\Observer\CustomerAuthObserver" />
99
</event>
10-
<event name="customer_login">
11-
<observer name="customer_2fa_login"
12-
instance="Elgentos\Frontend2FA\Observer\TfaFrontendCheck" />
13-
</event>
1410
</config>

0 commit comments

Comments
 (0)