diff --git a/ReCaptchaCustomer/Observer/EditCustomerObserver.php b/ReCaptchaCustomer/Observer/EditCustomerObserver.php new file mode 100644 index 00000000..6ab19f0e --- /dev/null +++ b/ReCaptchaCustomer/Observer/EditCustomerObserver.php @@ -0,0 +1,74 @@ +url = $url; + $this->isCaptchaEnabled = $isCaptchaEnabled; + $this->requestHandler = $requestHandler; + } + + /** + * @inheritdoc + * + * @param Observer $observer + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function execute(Observer $observer): void + { + $key = 'customer_edit'; + if ($this->isCaptchaEnabled->isCaptchaEnabledFor($key)) { + /** @var Action $controller */ + $controller = $observer->getControllerAction(); + $request = $controller->getRequest(); + $response = $controller->getResponse(); + $redirectOnFailureUrl = $this->url->getUrl('*/*/edit', ['_secure' => true]); + + $this->requestHandler->execute($key, $request, $response, $redirectOnFailureUrl); + } + } +} diff --git a/ReCaptchaCustomer/etc/adminhtml/system.xml b/ReCaptchaCustomer/etc/adminhtml/system.xml index a9ed7e6d..27b3bd28 100644 --- a/ReCaptchaCustomer/etc/adminhtml/system.xml +++ b/ReCaptchaCustomer/etc/adminhtml/system.xml @@ -25,6 +25,11 @@ Magento\ReCaptchaAdminUi\Model\OptionSource\Type + + + Magento\ReCaptchaAdminUi\Model\OptionSource\Type + diff --git a/ReCaptchaCustomer/etc/config.xml b/ReCaptchaCustomer/etc/config.xml index e3ead5e4..11ee5351 100644 --- a/ReCaptchaCustomer/etc/config.xml +++ b/ReCaptchaCustomer/etc/config.xml @@ -13,6 +13,7 @@ + diff --git a/ReCaptchaCustomer/etc/frontend/events.xml b/ReCaptchaCustomer/etc/frontend/events.xml index aec4e0a7..8166d9b6 100644 --- a/ReCaptchaCustomer/etc/frontend/events.xml +++ b/ReCaptchaCustomer/etc/frontend/events.xml @@ -16,6 +16,9 @@ + + + diff --git a/ReCaptchaCustomer/view/frontend/layout/customer_account_edit.xml b/ReCaptchaCustomer/view/frontend/layout/customer_account_edit.xml new file mode 100644 index 00000000..11a1de9a --- /dev/null +++ b/ReCaptchaCustomer/view/frontend/layout/customer_account_edit.xml @@ -0,0 +1,29 @@ + + + + + + + + customer_edit + + + + Magento_ReCaptchaFrontendUi/js/reCaptcha + + + + + + + + diff --git a/ReCaptchaCustomer/view/frontend/web/css/source/_module.less b/ReCaptchaCustomer/view/frontend/web/css/source/_module.less index 8ef62177..f2958ae5 100644 --- a/ReCaptchaCustomer/view/frontend/web/css/source/_module.less +++ b/ReCaptchaCustomer/view/frontend/web/css/source/_module.less @@ -2,7 +2,9 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -.login-container, .form-login { +.login-container, +.form-login, +.form-edit-account { .g-recaptcha { margin-bottom: 10px !important; }