From 0949cb5b565fd7906c0dcea4ea56312eb1c853fa Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 10 Mar 2023 10:14:03 +0530 Subject: [PATCH] Add patch for get by email --- Dockerfile | 3 +- patches/025-optimize-get-by-email.patch | 44 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 patches/025-optimize-get-by-email.patch diff --git a/Dockerfile b/Dockerfile index 0541a7f1..245b82cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ ARG ECLOUD_DASHBOARD_JOB_ID="525503" ARG SNAPPY_VERSION="2.26.3" ARG SNAPPY_THEME_VERSION="1.2.2" -RUN sed -i 's/24,0,10,1/24,0,10,7/' ${BASE_DIR}/version.php +RUN sed -i 's/24,0,10,1/24,0,10,8/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images @@ -165,6 +165,7 @@ RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete- RUN patch -u ${BASE_DIR}/core/templates/layout.guest.php -i ${TMP_PATCH_DIR}/016-login-screen.patch RUN patch -u ${BASE_DIR}/lib/private/Notification/Manager.php -i ${TMP_PATCH_DIR}/020-fairuse-notification-fix.patch RUN cd ${BASE_DIR} && patch -u ${BASE_DIR}/apps/user_ldap/lib/User_LDAP.php -i ${TMP_PATCH_DIR}/023-ldap-check-pwd-optimization.patch +RUN patch -u ${BASE_DIR}/lib/private/User/Manager.php -i ${TMP_PATCH_DIR}/025-optimize-get-by-email.patch RUN rm -rf ${TMP_PATCH_DIR} RUN curl -fsSL -o ldap_write_support.tar.gz \ diff --git a/patches/025-optimize-get-by-email.patch b/patches/025-optimize-get-by-email.patch new file mode 100644 index 00000000..7673feb2 --- /dev/null +++ b/patches/025-optimize-get-by-email.patch @@ -0,0 +1,44 @@ +From: Akhil +Date: Tue, 10 Mar 2023 10:00 +0530 +Subject: [PATCH] To optimize getByEmail as we have boundary conditions that email is unique per-user and can only match one of the two domains + +--- ./lib/private/User/Manager.php 2023-03-10 10:01:44.729561986 +0530 ++++ ./lib/private/User/Manager-new.php 2023-03-10 10:05:18.767230727 +0530 +@@ -706,11 +706,33 @@ + */ + public function getByEmail($email) { + // looking for 'email' only (and not primary_mail) is intentional +- $userIds = $this->config->getUsersForUserValueCaseInsensitive('settings', 'email', $email); ++ $mailDomain = $this->config->getSystemValue('mail_domain', ''); ++ $altMailDomain = $this->config->getSystemValue('alt_mail_domain', ''); ++ $users = []; ++ ++ if(empty($mailDomain) && empty($altMailDomain)) { ++ $userIds = $this->config->getUsersForUserValueCaseInsensitive('settings', 'email', $email); + +- $users = array_map(function ($uid) { +- return $this->get($uid); +- }, $userIds); ++ $users = array_map(function ($uid) { ++ return $this->get($uid); ++ }, $userIds); ++ } else { ++ $uid = ''; ++ $mailDomainSuffix = empty($mailDomain) ? '' : '@' . $mailDomain; ++ $altMailDomainSuffix = empty($altMailDomain) ? '' : '@' . $altMailDomain; ++ ++ if (!empty($mailDomainSuffix) && stristr($email, $mailDomainSuffix) !== FALSE) { ++ // In case of mail_domain, username is email ++ $uid = $email; ++ } else if (!empty($altMailDomainSuffix) && stristr($email, $altMailDomainSuffix) !== FALSE) { ++ // In case of alt_mail_domain, username is email without domain suffix ++ $uid = str_replace($altMailDomainSuffix, '', $email); ++ } ++ // If no match of domain, no user ++ if(!empty($uid)) { ++ $users = [$this->get($uid)]; ++ } ++ } + + return array_values(array_filter($users, function ($u) { + return ($u instanceof IUser); -- GitLab