diff --git a/CHANGELOG.md b/CHANGELOG.md index 50ee9122c..fdf5b08d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Added new `Pages::getSimplePagesHash` which is useful for caching pages specific data 1. [](#bugfix) * An attempt to workaround windows reading locked file issue [getgrav/grav-plugin-admin#2299](https://github.com/getgrav/grav-plugin-admin/issues/2299) + * Force user index file to be updated to fix email addresses [getgrav/grav-plugin-login#229](https://github.com/getgrav/grav-plugin-login/issues/229) # v1.7.36 ## 09/08/2022 @@ -15,7 +16,7 @@ * Added `authorize-*@:` support for Flex blueprints, e.g. `authorize-disabled@: not delete` disables the field if user does not have access to delete object * Added support for `flex-ignore@` to hide all the nested fields in the blueprint 1. [](#bugfix) - * Fixed loggin with a capitalised email address when using old users [getgrav/grav-plugin-login#229](https://github.com/getgrav/grav-plugin-login/issues/229) + * Fixed login with a capitalised email address when using old users [getgrav/grav-plugin-login#229](https://github.com/getgrav/grav-plugin-login/issues/229) # v1.7.35 ## 08/04/2022 diff --git a/system/src/Grav/Common/Flex/Types/Users/UserIndex.php b/system/src/Grav/Common/Flex/Types/Users/UserIndex.php index aff6e1570..868aad756 100644 --- a/system/src/Grav/Common/Flex/Types/Users/UserIndex.php +++ b/system/src/Grav/Common/Flex/Types/Users/UserIndex.php @@ -30,7 +30,7 @@ */ class UserIndex extends FlexIndex implements UserCollectionInterface { - public const VERSION = parent::VERSION . '.1'; + public const VERSION = parent::VERSION . '.2'; /** * @param FlexStorageInterface $storage @@ -50,7 +50,7 @@ public static function loadEntriesFromStorage(FlexStorageInterface $storage): ar // return $index['index']; //} - // Load up to date index. + // Load up-to-date index. $entries = parent::loadEntriesFromStorage($storage); return static::updateIndexFile($storage, $index['index'], $entries, ['force_update' => $force]); @@ -142,9 +142,11 @@ public function find($query, $fields = ['username', 'email']): UserInterface } elseif ($field === 'flex_key') { $user = $this->withKeyField('flex_key')->get($query); } elseif ($field === 'email') { - $user = $this->withKeyField('email')->get(static::filterUsername($query, $this->getFlexDirectory()->getStorage())); + $email = mb_strtolower($query); + $user = $this->withKeyField('email')->get($email); } elseif ($field === 'username') { - $user = $this->get(static::filterUsername($query, $this->getFlexDirectory()->getStorage())); + $username = static::filterUsername($query, $this->getFlexDirectory()->getStorage()); + $user = $this->get($username); } else { $user = $this->__call('find', [$query, $field]); }