Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 274a335d authored by Arnau Vàzquez's avatar Arnau Vàzquez
Browse files

Merge branch 'recovery-email-username-fix' into 'master'

Added changes to recovery email patch to allow username without domain suffix

See merge request !43
parents 9ebc2557 3267a8b7
Loading
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
FROM nextcloud:20.0.12-fpm
ARG BASE_DIR="/usr/src/nextcloud"
ARG TMP_PATCH_DIR="/tmp/build_patches"
ARG THEME_VERSION="20.1.1"
ARG THEME_HELPER_VERSION="1.0.0"
ARG THEME_VERSION="20.1.2"
ARG THEME_HELPER_VERSION="1.0.1"
ARG NEWS_VERSION="16.0.1"
ARG QUOTA_WARN_VERSION="1.9.1"
ARG NOTES_VERSION="4.1.1"
@@ -13,13 +13,14 @@ ARG EMAIL_RECOVERY_JOB_ID="199763"
ARG RAINLOOP_VERSION="7.1.2"
ARG RAINLOOP_COMMIT_SHA="aa5c57a7"
ARG EDA_TAG="nc-20"
ARG ECLOUD_LAUNCHER_JOB_ID="200382"
ARG ECLOUD_LAUNCHER_JOB_ID="204816"
ARG GOOGLE_INTEGRATION_VERSION="1.0.5-1-nightly"

RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images
COPY patches/ ${TMP_PATCH_DIR}/
COPY custom_entrypoint.sh /
RUN chmod +x /custom_entrypoint.sh
RUN sed -i 's/20,0,12,1/20,0,12,12/' ${BASE_DIR}/version.php
RUN sed -i 's/20,0,12,1/20,0,12,13/' ${BASE_DIR}/version.php

# Install unzip for unzipping artifacts
RUN apt-get update && apt-get install unzip 
@@ -85,12 +86,21 @@ RUN curl -fsSL -o ecloud-launcher.zip \
    mv dist/ecloud-launcher ${BASE_DIR}/custom_apps/ && \
    rm ecloud-launcher.zip;

RUN curl -fsSL -o integration_google.tar.gz \
    "https://github.com/nextcloud/integration_google/releases/download/v${GOOGLE_INTEGRATION_VERSION}/integration_google-${GOOGLE_INTEGRATION_VERSION}.tar.gz" && \
    tar -xf integration_google.tar.gz -C ${BASE_DIR}/custom_apps/ && \
    chown -R www-data:www-data ${BASE_DIR}/custom_apps/integration_google && \
    rm integration_google.tar.gz;

# Remove unzip when unzipping is done
RUN apt-get -y remove unzip

# force eCloud theme not to be disabled even when there is an upgrade process launched
RUN sed -i "s/\$systemConfig->setValue('theme', '');/\$systemConfig->setValue('theme', 'eCloud');/g" ${BASE_DIR}/lib/base.php

# fix min version of google data migration app
RUN sed -i "s/min-version=\"22\"/min-version=\"20\"/" ${BASE_DIR}/custom_apps/integration_google/appinfo/info.xml

# Patches
RUN patch -u ${BASE_DIR}/core/Controller/LoginController.php -i ${TMP_PATCH_DIR}/002-login-without-domain.patch
RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-contact-search-removal.patch
+25 −2
Original line number Diff line number Diff line
@@ -7,7 +7,21 @@ This patch adds the necessary changes to core NC controller and template for "em
diff --git ./core/Controller/LostController.php ./core/Controller/LostController.new.php
--- ./core/Controller/LostController.php	2021-03-26 09:51:09.317785801 +0530
+++ ./core/Controller/LostController.new.php	2021-03-26 09:51:35.490073707 +0530
@@ -205,8 +205,9 @@
@@ -194,6 +194,13 @@
 	 * @throws \Exception
 	 */
 	protected function checkPasswordResetToken($token, $userId) {
+		$domain = $this->config->getSystemValue("mail_domain");
+		$domainSuffix = "@$domain";
+
+		if(stristr($userId, $domainSuffix) === FALSE ) {
+			$userId = $userId . $domainSuffix;
+		}
+
 		$user = $this->userManager->get($userId);
 		if ($user === null || !$user->isEnabled()) {
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
@@ -205,8 +212,9 @@
 		}
 
 		try {
@@ -19,15 +33,24 @@ diff --git ./core/Controller/LostController.php ./core/Controller/LostController
 		} catch (\Exception $e) {
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
 		}
@@ -334,7 +335,7 @@
@@ -333,8 +341,15 @@
 	 * @throws \OCP\PreConditionNotMetException
 	 */
 	protected function sendEmail($input) {
+		$domain = $this->config->getSystemValue("mail_domain");
+		$domainSuffix = "@$domain";
+
+		if(stristr($input, $domainSuffix) === FALSE ) {
+			$input = $input . $domainSuffix;
+		}
+
 		$user = $this->findUserByIdOrMail($input);
-		$email = $user->getEMailAddress();
+		$email = $this->config->getUserValue($user->getUID(), 'email-recovery', 'recovery-email');
 
 		if (empty($email)) {
 			throw new ResetPasswordException('Could not send reset e-mail since there is no email for username ' . $input);

diff --git ./apps/settings/templates/settings/personal/personal.info.php ./apps/settings/templates/settings/personal/personal.info.new.php
--- ./apps/settings/templates/settings/personal/personal.info.php       2021-04-22 07:49:34.926418855 +0530
+++ ./apps/settings/templates/settings/personal/personal.info.new.php	2021-04-22 07:50:00.026660710 +0530