diff --git a/Plugin/AccountRedirectPlugin.php b/Plugin/AccountRedirectPlugin.php index 7d5b3dc..d571aff 100644 --- a/Plugin/AccountRedirectPlugin.php +++ b/Plugin/AccountRedirectPlugin.php @@ -13,9 +13,19 @@ public function __construct(private readonly CustomerSession $customerSession) { } + public function beforeGetRedirect(Redirect $subject): array + { + $beforeAuthUrl = $this->session->getBeforeAuthUrl(false); + if ($beforeAuthUrl) { + $this->customerSession->setBefore2faUrl($beforeAuthUrl); + } + + return []; + } + public function afterGetRedirectCookie(Redirect $subject, ?string $result): ?string { - if ($result && !$this->customerSession->getBefore2faUrl(false)) { + if ($result) { $this->customerSession->setBefore2faUrl($result); } diff --git a/Plugin/LoginPostPlugin.php b/Plugin/LoginPostPlugin.php index da13587..a244998 100644 --- a/Plugin/LoginPostPlugin.php +++ b/Plugin/LoginPostPlugin.php @@ -31,7 +31,7 @@ public function __construct( public function afterExecute(LoginPost $subject, Redirect $result): Redirect { if (!$this->config->isEnabled()) { - return $this; + return $result; } if ($this->customerSession->get2faSuccessful()) {