From 17ff4de5578df03b821ffe6fbd3d6b546f0e4d95 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 17 Jul 2024 00:25:24 +0530 Subject: [PATCH 01/13] Remove from restricted-users.map list if deleted --- lib/AppInfo/Application.php | 3 ++ lib/Listeners/BeforeUserDeletedListener.php | 37 +++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 lib/Listeners/BeforeUserDeletedListener.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 277036d..6889878 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -29,6 +29,7 @@ namespace OCA\EmailRecovery\AppInfo; use OCA\EmailRecovery\Listeners\BeforeTemplateRenderedListener; use OCA\EmailRecovery\Listeners\UserConfigChangedListener; use OCA\EmailRecovery\Listeners\UserChangedListener; +use OCA\EmailRecovery\Listeners\BeforeUserDeletedListener; use OCA\EmailRecovery\Listeners\BeforeUserRegisteredListener; use OCA\EmailRecovery\Notification\Notifier; use OCP\AppFramework\App; @@ -39,6 +40,7 @@ use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\Notification\IManager as INotificationManager; use OCP\User\Events\UserConfigChangedEvent; use OCP\User\Events\UserChangedEvent; +use OCP\User\Events\BeforeUserDeletedEvent; use OCA\EcloudAccounts\Event\BeforeUserRegisteredEvent; class Application extends App implements IBootstrap { @@ -53,6 +55,7 @@ class Application extends App implements IBootstrap { $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); $context->registerEventListener(UserConfigChangedEvent::class, UserConfigChangedListener::class); $context->registerEventListener(UserChangedEvent::class, UserChangedListener::class); + $context->registerEventListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class); } public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerNotifier']); diff --git a/lib/Listeners/BeforeUserDeletedListener.php b/lib/Listeners/BeforeUserDeletedListener.php new file mode 100644 index 0000000..a1b663f --- /dev/null +++ b/lib/Listeners/BeforeUserDeletedListener.php @@ -0,0 +1,37 @@ +logger = $logger; + $this->recoveryEmailService = $recoveryEmailService; + } + + public function handle(Event $event): void { + if (!($event instanceof BeforeUserDeletedEvent)) { + return; + } + + $userData = $event->getUser(); + try { + $userEmailAddress = $userData->getEMailAddress(); + if (!empty($newRecoveryEmail)) { + $this->recoveryEmailService->unrestrictEmail($userEmailAddress); + } + } catch (\Throwable $e) { + $this->logger->error('Error in removing email from restricted list: '.$e->getMessage()); + } + } +} -- GitLab From 21d23dac9a0175c269328e8920d3d9f9216d0fbb Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 17 Jul 2024 00:29:06 +0530 Subject: [PATCH 02/13] useremail --- lib/Listeners/BeforeUserDeletedListener.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Listeners/BeforeUserDeletedListener.php b/lib/Listeners/BeforeUserDeletedListener.php index a1b663f..fbf7d56 100644 --- a/lib/Listeners/BeforeUserDeletedListener.php +++ b/lib/Listeners/BeforeUserDeletedListener.php @@ -23,11 +23,10 @@ class BeforeUserDeletedListener implements IEventListener { if (!($event instanceof BeforeUserDeletedEvent)) { return; } - $userData = $event->getUser(); try { $userEmailAddress = $userData->getEMailAddress(); - if (!empty($newRecoveryEmail)) { + if (!empty($userEmailAddress)) { $this->recoveryEmailService->unrestrictEmail($userEmailAddress); } } catch (\Throwable $e) { -- GitLab From bcb8790e33f8486c128389f07d3a29c466871655 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 17 Jul 2024 19:24:04 +0530 Subject: [PATCH 03/13] UserDeletedevent used --- lib/AppInfo/Application.php | 6 +++--- ...eforeUserDeletedListener.php => UserDeletedListener.php} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename lib/Listeners/{BeforeUserDeletedListener.php => UserDeletedListener.php} (84%) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 6889878..b3df0ed 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -29,7 +29,7 @@ namespace OCA\EmailRecovery\AppInfo; use OCA\EmailRecovery\Listeners\BeforeTemplateRenderedListener; use OCA\EmailRecovery\Listeners\UserConfigChangedListener; use OCA\EmailRecovery\Listeners\UserChangedListener; -use OCA\EmailRecovery\Listeners\BeforeUserDeletedListener; +use OCA\EmailRecovery\Listeners\UserDeletedListener; use OCA\EmailRecovery\Listeners\BeforeUserRegisteredListener; use OCA\EmailRecovery\Notification\Notifier; use OCP\AppFramework\App; @@ -40,7 +40,7 @@ use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\Notification\IManager as INotificationManager; use OCP\User\Events\UserConfigChangedEvent; use OCP\User\Events\UserChangedEvent; -use OCP\User\Events\BeforeUserDeletedEvent; +use OCP\User\Events\UserDeletedEvent; use OCA\EcloudAccounts\Event\BeforeUserRegisteredEvent; class Application extends App implements IBootstrap { @@ -55,7 +55,7 @@ class Application extends App implements IBootstrap { $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); $context->registerEventListener(UserConfigChangedEvent::class, UserConfigChangedListener::class); $context->registerEventListener(UserChangedEvent::class, UserChangedListener::class); - $context->registerEventListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class); + $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); } public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerNotifier']); diff --git a/lib/Listeners/BeforeUserDeletedListener.php b/lib/Listeners/UserDeletedListener.php similarity index 84% rename from lib/Listeners/BeforeUserDeletedListener.php rename to lib/Listeners/UserDeletedListener.php index fbf7d56..d2183a9 100644 --- a/lib/Listeners/BeforeUserDeletedListener.php +++ b/lib/Listeners/UserDeletedListener.php @@ -8,9 +8,9 @@ use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\ILogger; -use OCP\User\Events\BeforeUserDeletedEvent; +use OCP\User\Events\UserDeletedEvent; -class BeforeUserDeletedListener implements IEventListener { +class UserDeletedListener implements IEventListener { private $logger; private $recoveryEmailService; @@ -20,7 +20,7 @@ class BeforeUserDeletedListener implements IEventListener { } public function handle(Event $event): void { - if (!($event instanceof BeforeUserDeletedEvent)) { + if (!($event instanceof UserDeletedEvent)) { return; } $userData = $event->getUser(); -- GitLab From c1846c4616d7aaae0b5053828c79524d31828c7e Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 17 Jul 2024 23:03:01 +0530 Subject: [PATCH 04/13] tem --- lib/Listeners/UserDeletedListener.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Listeners/UserDeletedListener.php b/lib/Listeners/UserDeletedListener.php index d2183a9..28ee469 100644 --- a/lib/Listeners/UserDeletedListener.php +++ b/lib/Listeners/UserDeletedListener.php @@ -20,12 +20,14 @@ class UserDeletedListener implements IEventListener { } public function handle(Event $event): void { + $this->logger->error('delete event listenere called...'); if (!($event instanceof UserDeletedEvent)) { return; } $userData = $event->getUser(); try { $userEmailAddress = $userData->getEMailAddress(); + $this->logger->error('userEmailAddress ==>: '.$userEmailAddress); if (!empty($userEmailAddress)) { $this->recoveryEmailService->unrestrictEmail($userEmailAddress); } -- GitLab From 1c4de79dd86e4e541fad78cd9eac1b53093b1ebd Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 18 Jul 2024 00:06:48 +0530 Subject: [PATCH 05/13] remove temp change --- lib/Listeners/UserDeletedListener.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Listeners/UserDeletedListener.php b/lib/Listeners/UserDeletedListener.php index 28ee469..062fab7 100644 --- a/lib/Listeners/UserDeletedListener.php +++ b/lib/Listeners/UserDeletedListener.php @@ -20,7 +20,6 @@ class UserDeletedListener implements IEventListener { } public function handle(Event $event): void { - $this->logger->error('delete event listenere called...'); if (!($event instanceof UserDeletedEvent)) { return; } -- GitLab From 61e181e2884d54a4818423b3c988c6af9a1f0afb Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 18 Jul 2024 00:07:05 +0530 Subject: [PATCH 06/13] remove temp change --- lib/Listeners/UserDeletedListener.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Listeners/UserDeletedListener.php b/lib/Listeners/UserDeletedListener.php index 062fab7..d2183a9 100644 --- a/lib/Listeners/UserDeletedListener.php +++ b/lib/Listeners/UserDeletedListener.php @@ -26,7 +26,6 @@ class UserDeletedListener implements IEventListener { $userData = $event->getUser(); try { $userEmailAddress = $userData->getEMailAddress(); - $this->logger->error('userEmailAddress ==>: '.$userEmailAddress); if (!empty($userEmailAddress)) { $this->recoveryEmailService->unrestrictEmail($userEmailAddress); } -- GitLab From 152c8f62ead8441f72c8e379b8feae3003d8c35e Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 18 Jul 2024 13:17:52 +0530 Subject: [PATCH 07/13] added lang --- lib/Controller/EmailRecoveryApiController.php | 2 +- lib/Controller/EmailRecoveryController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Controller/EmailRecoveryApiController.php b/lib/Controller/EmailRecoveryApiController.php index f60a18f..51faabe 100644 --- a/lib/Controller/EmailRecoveryApiController.php +++ b/lib/Controller/EmailRecoveryApiController.php @@ -77,7 +77,7 @@ class EmailRecoveryApiController extends ApiController { } try { - if ($this->recoveryEmailService->validateRecoveryEmail($id, $email)) { + if ($this->recoveryEmailService->validateRecoveryEmail($id, $email, 'en')) { $this->recoveryEmailService->updateRecoveryEmail($id, $email); return $response; } diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index d9230c6..00bea58 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -175,7 +175,7 @@ class EmailRecoveryController extends Controller { private function handleRecoveryEmailLogic(string $recoveryEmail, string $userId, JSONResponse $response) { try { - if ($this->recoveryEmailService->validateRecoveryEmail($userId, $recoveryEmail)) { + if ($this->recoveryEmailService->validateRecoveryEmail($userId, $recoveryEmail, 'en')) { $this->recoveryEmailService->updateRecoveryEmail($userId, $recoveryEmail); $response->setStatus(200); } -- GitLab From 4c45a835e097fc94856452df698ed2fcc413736c Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 18 Jul 2024 15:07:57 +0530 Subject: [PATCH 08/13] userManager added --- lib/Listeners/UserDeletedListener.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Listeners/UserDeletedListener.php b/lib/Listeners/UserDeletedListener.php index d2183a9..4e47ad6 100644 --- a/lib/Listeners/UserDeletedListener.php +++ b/lib/Listeners/UserDeletedListener.php @@ -9,22 +9,27 @@ use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\ILogger; use OCP\User\Events\UserDeletedEvent; +use OCP\IUserManager; class UserDeletedListener implements IEventListener { private $logger; private $recoveryEmailService; + private $userManager; - public function __construct(ILogger $logger, RecoveryEmailService $recoveryEmailService) { + public function __construct(ILogger $logger, RecoveryEmailService $recoveryEmailService, IUserManager $userManager) { $this->logger = $logger; $this->recoveryEmailService = $recoveryEmailService; + $this->userManager = $userManager; } public function handle(Event $event): void { + $this->logger->error('In user deleted listener.'); if (!($event instanceof UserDeletedEvent)) { return; } - $userData = $event->getUser(); + $user = $event->getUser(); try { + $userData = $this->userManager->get($user); $userEmailAddress = $userData->getEMailAddress(); if (!empty($userEmailAddress)) { $this->recoveryEmailService->unrestrictEmail($userEmailAddress); -- GitLab From d0ca2549e6a46b6153bf7b05a58da37e60358e84 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 18 Jul 2024 15:25:00 +0530 Subject: [PATCH 09/13] added email --- lib/Listeners/UserDeletedListener.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Listeners/UserDeletedListener.php b/lib/Listeners/UserDeletedListener.php index 4e47ad6..3df8b93 100644 --- a/lib/Listeners/UserDeletedListener.php +++ b/lib/Listeners/UserDeletedListener.php @@ -27,10 +27,12 @@ class UserDeletedListener implements IEventListener { if (!($event instanceof UserDeletedEvent)) { return; } - $user = $event->getUser(); + $user = $event->getUser()->getUID(); + $this->logger->error('user::'.$user); try { $userData = $this->userManager->get($user); $userEmailAddress = $userData->getEMailAddress(); + $this->logger->error('EmailAddress::'.$userEmailAddress); if (!empty($userEmailAddress)) { $this->recoveryEmailService->unrestrictEmail($userEmailAddress); } -- GitLab From 10a18617d3564ecda8aea602211af3047760d30c Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 18 Jul 2024 15:40:16 +0530 Subject: [PATCH 10/13] reverted to beforeuserdeletedevent --- lib/AppInfo/Application.php | 6 +++--- ...DeletedListener.php => BeforeUserDeletedListener.php} | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) rename lib/Listeners/{UserDeletedListener.php => BeforeUserDeletedListener.php} (77%) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index b3df0ed..6889878 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -29,7 +29,7 @@ namespace OCA\EmailRecovery\AppInfo; use OCA\EmailRecovery\Listeners\BeforeTemplateRenderedListener; use OCA\EmailRecovery\Listeners\UserConfigChangedListener; use OCA\EmailRecovery\Listeners\UserChangedListener; -use OCA\EmailRecovery\Listeners\UserDeletedListener; +use OCA\EmailRecovery\Listeners\BeforeUserDeletedListener; use OCA\EmailRecovery\Listeners\BeforeUserRegisteredListener; use OCA\EmailRecovery\Notification\Notifier; use OCP\AppFramework\App; @@ -40,7 +40,7 @@ use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\Notification\IManager as INotificationManager; use OCP\User\Events\UserConfigChangedEvent; use OCP\User\Events\UserChangedEvent; -use OCP\User\Events\UserDeletedEvent; +use OCP\User\Events\BeforeUserDeletedEvent; use OCA\EcloudAccounts\Event\BeforeUserRegisteredEvent; class Application extends App implements IBootstrap { @@ -55,7 +55,7 @@ class Application extends App implements IBootstrap { $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); $context->registerEventListener(UserConfigChangedEvent::class, UserConfigChangedListener::class); $context->registerEventListener(UserChangedEvent::class, UserChangedListener::class); - $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); + $context->registerEventListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class); } public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerNotifier']); diff --git a/lib/Listeners/UserDeletedListener.php b/lib/Listeners/BeforeUserDeletedListener.php similarity index 77% rename from lib/Listeners/UserDeletedListener.php rename to lib/Listeners/BeforeUserDeletedListener.php index 3df8b93..ae28c0c 100644 --- a/lib/Listeners/UserDeletedListener.php +++ b/lib/Listeners/BeforeUserDeletedListener.php @@ -8,10 +8,10 @@ use OCA\EmailRecovery\Service\RecoveryEmailService; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\ILogger; -use OCP\User\Events\UserDeletedEvent; +use OCP\User\Events\BeforeUserDeletedEvent; use OCP\IUserManager; -class UserDeletedListener implements IEventListener { +class BeforeUserDeletedListener implements IEventListener { private $logger; private $recoveryEmailService; private $userManager; @@ -23,16 +23,13 @@ class UserDeletedListener implements IEventListener { } public function handle(Event $event): void { - $this->logger->error('In user deleted listener.'); - if (!($event instanceof UserDeletedEvent)) { + if (!($event instanceof BeforeUserDeletedEvent)) { return; } $user = $event->getUser()->getUID(); - $this->logger->error('user::'.$user); try { $userData = $this->userManager->get($user); $userEmailAddress = $userData->getEMailAddress(); - $this->logger->error('EmailAddress::'.$userEmailAddress); if (!empty($userEmailAddress)) { $this->recoveryEmailService->unrestrictEmail($userEmailAddress); } -- GitLab From 4af0c936d0d1e1bada752d72a560836f5c78d46b Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 19 Jul 2024 15:41:17 +0530 Subject: [PATCH 11/13] changing argument position --- lib/Controller/EmailRecoveryApiController.php | 2 +- lib/Controller/EmailRecoveryController.php | 2 +- lib/Listeners/BeforeUserRegisteredListener.php | 2 +- lib/Service/RecoveryEmailService.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Controller/EmailRecoveryApiController.php b/lib/Controller/EmailRecoveryApiController.php index 51faabe..daf9a97 100644 --- a/lib/Controller/EmailRecoveryApiController.php +++ b/lib/Controller/EmailRecoveryApiController.php @@ -77,7 +77,7 @@ class EmailRecoveryApiController extends ApiController { } try { - if ($this->recoveryEmailService->validateRecoveryEmail($id, $email, 'en')) { + if ($this->recoveryEmailService->validateRecoveryEmail($email, $id, 'en')) { $this->recoveryEmailService->updateRecoveryEmail($id, $email); return $response; } diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index 00bea58..ce77a6d 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -175,7 +175,7 @@ class EmailRecoveryController extends Controller { private function handleRecoveryEmailLogic(string $recoveryEmail, string $userId, JSONResponse $response) { try { - if ($this->recoveryEmailService->validateRecoveryEmail($userId, $recoveryEmail, 'en')) { + if ($this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, $userId, 'en')) { $this->recoveryEmailService->updateRecoveryEmail($userId, $recoveryEmail); $response->setStatus(200); } diff --git a/lib/Listeners/BeforeUserRegisteredListener.php b/lib/Listeners/BeforeUserRegisteredListener.php index 5e598bf..5d258a3 100644 --- a/lib/Listeners/BeforeUserRegisteredListener.php +++ b/lib/Listeners/BeforeUserRegisteredListener.php @@ -36,7 +36,7 @@ class BeforeUserRegisteredListener implements IEventListener { */ protected function validateRecoveryEmail(string $recoveryEmail, string $language): void { try { - $this->recoveryEmailService->validateRecoveryEmail('', $recoveryEmail, $language); + $this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, '', $language); } catch (\Exception $e) { throw new RecoveryEmailValidationException($e->getMessage()); } diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index d6892c8..e71d198 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -109,7 +109,7 @@ class RecoveryEmailService { return true; } - public function validateRecoveryEmail(string $username = '', string $recoveryEmail, string $language = 'en') : bool { + public function validateRecoveryEmail(string $recoveryEmail, string $username = '', string $language = 'en') : bool { $email = ''; if ($username != '') { $user = $this->userManager->get($username); -- GitLab From 5a880925438e52ba69977e29b49de8604d0541c2 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 19 Jul 2024 15:43:02 +0530 Subject: [PATCH 12/13] reordering arguments --- lib/Controller/EmailRecoveryApiController.php | 2 +- lib/Controller/EmailRecoveryController.php | 2 +- lib/Listeners/BeforeUserRegisteredListener.php | 2 +- lib/Service/RecoveryEmailService.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Controller/EmailRecoveryApiController.php b/lib/Controller/EmailRecoveryApiController.php index daf9a97..09d8c2c 100644 --- a/lib/Controller/EmailRecoveryApiController.php +++ b/lib/Controller/EmailRecoveryApiController.php @@ -77,7 +77,7 @@ class EmailRecoveryApiController extends ApiController { } try { - if ($this->recoveryEmailService->validateRecoveryEmail($email, $id, 'en')) { + if ($this->recoveryEmailService->validateRecoveryEmail($email, 'en', $id)) { $this->recoveryEmailService->updateRecoveryEmail($id, $email); return $response; } diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index ce77a6d..7468040 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -175,7 +175,7 @@ class EmailRecoveryController extends Controller { private function handleRecoveryEmailLogic(string $recoveryEmail, string $userId, JSONResponse $response) { try { - if ($this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, $userId, 'en')) { + if ($this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, 'en', $userId)) { $this->recoveryEmailService->updateRecoveryEmail($userId, $recoveryEmail); $response->setStatus(200); } diff --git a/lib/Listeners/BeforeUserRegisteredListener.php b/lib/Listeners/BeforeUserRegisteredListener.php index 5d258a3..37aa7a7 100644 --- a/lib/Listeners/BeforeUserRegisteredListener.php +++ b/lib/Listeners/BeforeUserRegisteredListener.php @@ -36,7 +36,7 @@ class BeforeUserRegisteredListener implements IEventListener { */ protected function validateRecoveryEmail(string $recoveryEmail, string $language): void { try { - $this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, '', $language); + $this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, $language); } catch (\Exception $e) { throw new RecoveryEmailValidationException($e->getMessage()); } diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index e71d198..60359a9 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -109,7 +109,7 @@ class RecoveryEmailService { return true; } - public function validateRecoveryEmail(string $recoveryEmail, string $username = '', string $language = 'en') : bool { + public function validateRecoveryEmail(string $recoveryEmail, string $language = 'en', string $username = '') : bool { $email = ''; if ($username != '') { $user = $this->userManager->get($username); -- GitLab From d84f6c9b878943c3bc177b5228e7dd70da4c7b55 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 19 Jul 2024 15:55:44 +0530 Subject: [PATCH 13/13] change in email , id, lang position --- lib/Controller/EmailRecoveryApiController.php | 2 +- lib/Controller/EmailRecoveryController.php | 2 +- lib/Listeners/BeforeUserRegisteredListener.php | 2 +- lib/Service/RecoveryEmailService.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Controller/EmailRecoveryApiController.php b/lib/Controller/EmailRecoveryApiController.php index 09d8c2c..ccda360 100644 --- a/lib/Controller/EmailRecoveryApiController.php +++ b/lib/Controller/EmailRecoveryApiController.php @@ -77,7 +77,7 @@ class EmailRecoveryApiController extends ApiController { } try { - if ($this->recoveryEmailService->validateRecoveryEmail($email, 'en', $id)) { + if ($this->recoveryEmailService->validateRecoveryEmail($email, $id)) { $this->recoveryEmailService->updateRecoveryEmail($id, $email); return $response; } diff --git a/lib/Controller/EmailRecoveryController.php b/lib/Controller/EmailRecoveryController.php index 7468040..e7fc331 100644 --- a/lib/Controller/EmailRecoveryController.php +++ b/lib/Controller/EmailRecoveryController.php @@ -175,7 +175,7 @@ class EmailRecoveryController extends Controller { private function handleRecoveryEmailLogic(string $recoveryEmail, string $userId, JSONResponse $response) { try { - if ($this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, 'en', $userId)) { + if ($this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, $userId)) { $this->recoveryEmailService->updateRecoveryEmail($userId, $recoveryEmail); $response->setStatus(200); } diff --git a/lib/Listeners/BeforeUserRegisteredListener.php b/lib/Listeners/BeforeUserRegisteredListener.php index 37aa7a7..5d258a3 100644 --- a/lib/Listeners/BeforeUserRegisteredListener.php +++ b/lib/Listeners/BeforeUserRegisteredListener.php @@ -36,7 +36,7 @@ class BeforeUserRegisteredListener implements IEventListener { */ protected function validateRecoveryEmail(string $recoveryEmail, string $language): void { try { - $this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, $language); + $this->recoveryEmailService->validateRecoveryEmail($recoveryEmail, '', $language); } catch (\Exception $e) { throw new RecoveryEmailValidationException($e->getMessage()); } diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 60359a9..e71d198 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -109,7 +109,7 @@ class RecoveryEmailService { return true; } - public function validateRecoveryEmail(string $recoveryEmail, string $language = 'en', string $username = '') : bool { + public function validateRecoveryEmail(string $recoveryEmail, string $username = '', string $language = 'en') : bool { $email = ''; if ($username != '') { $user = $this->userManager->get($username); -- GitLab