From 8ff3da52654ed5c43aff9426acfe29a2045645ab Mon Sep 17 00:00:00 2001 From: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com> Date: Wed, 8 Feb 2023 13:57:26 +0100 Subject: [PATCH] Disable password reset via Hooks --- src/modules/Client/Api/Guest.php | 2 ++ src/modules/Client/Controller/Client.php | 1 + src/modules/Staff/Api/Guest.php | 1 + src/modules/Staff/Controller/Admin.php | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/Client/Api/Guest.php b/src/modules/Client/Api/Guest.php index d1339e911..10f0f500f 100644 --- a/src/modules/Client/Api/Guest.php +++ b/src/modules/Client/Api/Guest.php @@ -171,6 +171,7 @@ class Guest extends \Api_Abstract */ public function reset_password($data) { + $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetClient']); $required = [ 'email' => 'Email required', ]; @@ -221,6 +222,7 @@ class Guest extends \Api_Abstract $required = [ 'hash' => 'Hash required', ]; + $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetClient']); $this->di['validator']->checkRequiredParamsForArray($required, $data); $reset = $this->di['db']->findOne('ClientPasswordReset', 'hash = ?', [$data['hash']]); diff --git a/src/modules/Client/Controller/Client.php b/src/modules/Client/Controller/Client.php index 3f63fc83b..8a5400168 100644 --- a/src/modules/Client/Controller/Client.php +++ b/src/modules/Client/Controller/Client.php @@ -79,6 +79,7 @@ class Client implements \Box\InjectionAwareInterface public function get_reset_password_confirm(\Box_App $app, $hash) { $api = $this->di['api_guest']; + $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetClient']); $data = [ 'hash' => $hash, ]; diff --git a/src/modules/Staff/Api/Guest.php b/src/modules/Staff/Api/Guest.php index 9249d4f34..0ebc3f754 100644 --- a/src/modules/Staff/Api/Guest.php +++ b/src/modules/Staff/Api/Guest.php @@ -99,6 +99,7 @@ class Guest extends \Api_Abstract } public function passwordreset($data){ + $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetStaff']); $required = [ 'email' => 'Email required', ]; diff --git a/src/modules/Staff/Controller/Admin.php b/src/modules/Staff/Controller/Admin.php index 718eb0c3a..7f7e79ebb 100644 --- a/src/modules/Staff/Controller/Admin.php +++ b/src/modules/Staff/Controller/Admin.php @@ -120,7 +120,7 @@ class Admin implements InjectionAwareInterface public function get_confirmation(\Box_App $app, $hash) { $service = $this->di['mod_service']('staff'); - + $this->di['events_manager']->fire(['event' => 'onBeforePasswordResetStaff']); // send confirmation email $service->sendPasswordResetConfirmation($hash); $this->di['logger']->info('Admin password reset request was approved');