From 8c5e80b21d415a5a0505e742b2ae62006c345701 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Jan 2019 17:06:16 +0100 Subject: [PATCH] Login via Email Address is handled by the LoginController Signed-off-by: Joas Schilling --- lib/imap.php | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/lib/imap.php b/lib/imap.php index 604674d..a412da2 100644 --- a/lib/imap.php +++ b/lib/imap.php @@ -52,39 +52,21 @@ class OC_User_IMAP extends \OCA\user_external\Base { $uid = str_replace("%40","@",$uid); } - $query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); - $query->select('userid') - ->from('preferences') - ->where($query->expr()->eq('appid', $query->createNamedParameter('settings'))) - ->andWhere($query->expr()->eq('configkey', $query->createNamedParameter('email'))) - ->andWhere($query->expr()->eq('configvalue', $query->createNamedParameter($uid))); - $result = $query->execute(); - - $users = []; - while ($row = $result->fetch()) { - $users[] = $row['userid']; - } - $result->closeCursor(); - - if(count($users) === 1) { + if ($this->domain !== '') { + $pieces = explode('@', $uid); + if (count($pieces) === 1) { + $username = $uid . '@' . $this->domain; + } else if(count($pieces) === 2 && $pieces[1] === $this->domain) { + $username = $uid; + $uid = $pieces[0]; + } else { + return false; + } + } else { $username = $uid; - $uid = $users[0]; - // Check if we only want logins from ONE domain and strip the domain part from UID - }elseif($this->domain !== '') { - $pieces = explode('@', $uid); - if(count($pieces) === 1) { - $username = $uid . "@" . $this->domain; - }elseif((count($pieces) === 2) && ($pieces[1] === $this->domain)) { - $username = $uid; - $uid = $pieces[0]; - }else{ - return false; - } - }else{ - $username = $uid; } - $mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1); + $mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1); imap_errors(); imap_alerts(); if($mbox !== false) {