Skip to content

Commit

Permalink
[BUGFIX] Return empty array when user can't be found
Browse files Browse the repository at this point in the history
FrontendUserRepository::fetchUserInformationByEmail now returns
empty array when there is no user with given email.

Resolves: #92601
Releases: master, 10.4
Change-Id: Iad1d862de9e7c59879b4cfebdf15bc0d8e7fde55
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/66131
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
tmotyl authored and maddy2101 committed Oct 19, 2020
1 parent cd94f3d commit e5d438e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -129,7 +129,8 @@ public function updateForgotHashForUserByEmail(string $emailAddress, string $has
}

/**
* Fetches array containing uid, username, email, first_name, middle_name & last_name by email.
* Fetches array containing uid, username, email, first_name, middle_name & last_name by email
* or empty array if user was not found.
*
* @param string $emailAddress
* @return array
Expand All @@ -148,8 +149,11 @@ public function fetchUserInformationByEmail(string $emailAddress): array
)
)
;

return $query->execute()->fetch(FetchMode::ASSOCIATIVE);
$result = $query->execute()->fetch(FetchMode::ASSOCIATIVE);
if (!is_array($result)) {
$result = [];
}
return $result;
}

/**
Expand Down
Expand Up @@ -124,6 +124,10 @@ public function fetchUserInformationByEmailDataProvider(): array
'last_name' => '',
]
],
'non existing user' => [
'non-existing@user.com',
[]
],
];
}

Expand Down

0 comments on commit e5d438e

Please sign in to comment.