mirror of
https://github.com/getgrav/grav.git
synced 2025-12-06 15:59:58 +01:00
Imroved UserIndex:find() to only search user if query isn't empty
This commit is contained in:
@@ -80,6 +80,7 @@ class UserIndex extends FlexIndex
|
|||||||
*/
|
*/
|
||||||
public function find($query, $fields = ['username', 'email']): UserInterface
|
public function find($query, $fields = ['username', 'email']): UserInterface
|
||||||
{
|
{
|
||||||
|
if (is_string($query) && $query !== '') {
|
||||||
foreach ((array)$fields as $field) {
|
foreach ((array)$fields as $field) {
|
||||||
if ($field === 'key') {
|
if ($field === 'key') {
|
||||||
$user = $this->get($query);
|
$user = $this->get($query);
|
||||||
@@ -98,6 +99,7 @@ class UserIndex extends FlexIndex
|
|||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->load('');
|
return $this->load('');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user