diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-12-20 11:09:10 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-12-20 14:19:35 +0100 |
commit | 03fe2b3b812e68765b5df6cb27e7f352ebbc2f87 (patch) | |
tree | f05c33029dfdd8b79a3e0fb708627a102a4e15f8 /lib | |
parent | 6146c474850557c16d5ac03477e9f8664b2555a7 (diff) | |
download | nextcloud-server-03fe2b3b812e68765b5df6cb27e7f352ebbc2f87.tar.gz nextcloud-server-03fe2b3b812e68765b5df6cb27e7f352ebbc2f87.zip |
Use a case insensitive search for email
Fixes #7084
Now entering wrongly cased email (roeland@ instead of Roeland@) for
password reset etc. Will also work.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AllConfig.php | 32 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 2 |
2 files changed, 33 insertions, 1 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 58706e290fb..09520aae2a9 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -459,6 +459,38 @@ class AllConfig implements \OCP\IConfig { return $userIDs; } + /** + * Determines the users that have the given value set for a specific app-key-pair + * + * @param string $appName the app to get the user for + * @param string $key the key to get the user for + * @param string $value the value to get the user for + * @return array of user IDs + */ + public function getUsersForUserValueCaseInsensitive($appName, $key, $value) { + // TODO - FIXME + $this->fixDIInit(); + + $sql = 'SELECT `userid` FROM `*PREFIX*preferences` ' . + 'WHERE `appid` = ? AND `configkey` = ? '; + + if($this->getSystemValue('dbtype', 'sqlite') === 'oci') { + //oracle hack: need to explicitly cast CLOB to CHAR for comparison + $sql .= 'AND LOWER(to_char(`configvalue`)) = LOWER(?)'; + } else { + $sql .= 'AND LOWER(`configvalue`) = LOWER(?)'; + } + + $result = $this->connection->executeQuery($sql, array($appName, $key, $value)); + + $userIDs = array(); + while ($row = $result->fetch()) { + $userIDs[] = $row['userid']; + } + + return $userIDs; + } + public function getSystemConfig() { return $this->systemConfig; } diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 4243ced2e98..f1a2029a7d5 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -589,7 +589,7 @@ class Manager extends PublicEmitter implements IUserManager { * @since 9.1.0 */ public function getByEmail($email) { - $userIds = $this->config->getUsersForUserValue('settings', 'email', $email); + $userIds = $this->config->getUsersForUserValueCaseInsensitive('settings', 'email', $email); $users = array_map(function($uid) { return $this->get($uid); |