diff --git a/lib/Listeners/UserConfigChangedListener.php b/lib/Listeners/UserConfigChangedListener.php index bfce357f17f6133ff8820bb74c25c707a9dbe153..10d845d09a72af177a8c2fcad6dfe4d529eecfa7 100644 --- a/lib/Listeners/UserConfigChangedListener.php +++ b/lib/Listeners/UserConfigChangedListener.php @@ -31,5 +31,10 @@ class UserConfigChangedListener implements IEventListener { $this->recoveryEmailService->sendVerificationEmail($user, $newRecoveryEmail); } } + if ($event->getKey() === 'recovery-email') { + $user = $event->getUserId(); + $newRecoveryEmail = $event->getValue(); + $this->recoveryEmailService->updateRecoveryEmailAtLDAPServer($user, $newRecoveryEmail); + } } } diff --git a/lib/Service/RecoveryEmailService.php b/lib/Service/RecoveryEmailService.php index 4b6e29ff50550f7c1ea478d01bd6dfceadd91f3f..3ed2384ac4dbcfc8b5c7ae04b66f0511c85ded4c 100644 --- a/lib/Service/RecoveryEmailService.php +++ b/lib/Service/RecoveryEmailService.php @@ -127,16 +127,12 @@ class RecoveryEmailService { } public function updateRecoveryEmail(string $username, string $recoveryEmail) : void { - $user = $this->userManager->get($username); - if ($this->LDAPConnectionService->isUserOnLDAPBackend($user) && $this->LDAPConnectionService->isLDAPEnabled()) { - $this->updateRecoveryEmailAtLDAPServer($username, $recoveryEmail); - } $this->setUnverifiedRecoveryEmail($username, $recoveryEmail); $this->setRecoveryEmail($username, ''); } - private function updateRecoveryEmailAtLDAPServer(string $username, $recoveryEmail) { + public function updateRecoveryEmailAtLDAPServer(string $username, $recoveryEmail) { $conn = $this->LDAPConnectionService->getLDAPConnection(); $userDn = $this->LDAPConnectionService->username2dn($username); $entry = [