summaryrefslogtreecommitdiffstats
path: root/core/Controller
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2018-09-13 10:48:30 +0200
committerGitHub <noreply@github.com>2018-09-13 10:48:30 +0200
commitef97ef72f6a505430b2e71dc44f3433167b5500c (patch)
treee5490ac2740d4afa8b6d6092560499721f732501 /core/Controller
parentd1cb83424feb5bd96f49e657d20b912cddfdd3d3 (diff)
parent031fdfb1fc3b99c7a7dd93ee20fe000e9cf7fda6 (diff)
downloadnextcloud-server-ef97ef72f6a505430b2e71dc44f3433167b5500c.tar.gz
nextcloud-server-ef97ef72f6a505430b2e71dc44f3433167b5500c.zip
Merge pull request #10743 from danielkesselberg/bugfix/noid/allow-password-reset-for-duplicate-email
Enable password reset for user with same email address when only one is active
Diffstat (limited to 'core/Controller')
-rw-r--r--core/Controller/LostController.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php
index ab5a10b8035..8d1481dfc28 100644
--- a/core/Controller/LostController.php
+++ b/core/Controller/LostController.php
@@ -364,24 +364,27 @@ class LostController extends Controller {
* @throws \InvalidArgumentException
*/
protected function findUserByIdOrMail($input) {
+ $userNotFound = new \InvalidArgumentException(
+ $this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.')
+ );
+
$user = $this->userManager->get($input);
if ($user instanceof IUser) {
if (!$user->isEnabled()) {
- throw new \InvalidArgumentException($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
+ throw $userNotFound;
}
return $user;
}
- $users = $this->userManager->getByEmail($input);
- if (count($users) === 1) {
- $user = $users[0];
- if (!$user->isEnabled()) {
- throw new \InvalidArgumentException($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
- }
- return $user;
+ $users = \array_filter($this->userManager->getByEmail($input), function (IUser $user) {
+ return $user->isEnabled();
+ });
+
+ if (\count($users) === 1) {
+ return $users[0];
}
- throw new \InvalidArgumentException($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
+ throw $userNotFound;
}
}