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

Commit 0ffe7d2b authored by Arnau Vàzquez's avatar Arnau Vàzquez
Browse files

Adjust remaining patches.

 - Email field readonly missing.
parent 708ec545
Loading
Loading
Loading
Loading
Loading
+30 −43
Original line number Diff line number Diff line
From: Akhil <akhil@e.email>
Date: Thu, 22 Apr 2021 07:50:00 +0530
From: ArnauVP <arnauvp@e.email>
Date: Thu, 23 Mar 2022 11:10:00 +0000
Subject: [PATCH] Makes password reset links use recovery email set through "email-recovery" app, makes "email" uneditable by user

This patch adds the necessary changes to core NC controller and template for "email-recovery" app to work correctly. Instead of the user's email address, the user's recovery email address set through the "email-recovery" app is used for the password reset email. Further the user's "email" in the template(so that users cannot edit it).
This patch adds the necessary changes to core NC controller and template for "email-recovery" app to work correctly. Instead of the user's email address, the user's recovery email address set through the "email-recovery" app is used for the password reset email.

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
@@ -194,6 +194,13 @@
--- ./core/Controller/LostController.php	2022-03-23 12:00:12.000000000 +0100
+++ ./core/Controller/LostController.new.php	2022-03-23 12:06:45.000000000 +0100
@@ -173,9 +173,19 @@
 	 * @throws \Exception
 	 */
 	protected function checkPasswordResetToken($token, $userId) {
 	protected function checkPasswordResetToken(string $token, string $userId): void {
+		$domain = $this->config->getSystemValue("mail_domain");
+		$domainSuffix = "@$domain";
+
@@ -18,25 +18,20 @@ diff --git ./core/Controller/LostController.php ./core/Controller/LostController
+			$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 {
-			$mailAddress = !is_null($user->getEMailAddress()) ? $user->getEMailAddress() : '';
-			$decryptedToken = $this->crypto->decrypt($encryptedToken, $mailAddress.$this->config->getSystemValue('secret'));
+		$recoveryEmail = $this->config->getUserValue($userId, 'email-recovery', 'recovery-email');
+		$mailAddress = is_null($recoveryEmail) ? '' : $recoveryEmail;
+ 			$decryptedToken = $this->crypto->decrypt($encryptedToken, $mailAddress.$this->config->getSystemValue('secret'));
 		} catch (\Exception $e) {
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
+
 		try {
 			$user = $this->userManager->get($userId);
-			$this->verificationToken->check($token, $user, 'lostpassword', $user ? $user->getEMailAddress() : '', true);
+			$this->verificationToken->check($token, $user, 'lostpassword', $mailAddress, true);
 		} catch (InvalidTokenException $e) {
 			$error = $e->getCode() === InvalidTokenException::TOKEN_EXPIRED
 				? $this->l10n->t('Could not reset password because the token is expired')
@@ -214,6 +224,13 @@
 			return new JSONResponse($this->error($this->l10n->t('Password reset is disabled')));
 		}
@@ -333,8 +341,15 @@
 	 * @throws \OCP\PreConditionNotMetException
 	 */
 	protected function sendEmail($input) {

+		$domain = $this->config->getSystemValue("mail_domain");
+        $domainSuffix = "@$domain";
+
@@ -44,23 +39,15 @@ diff --git ./core/Controller/LostController.php ./core/Controller/LostController
+            $input = $input . $domainSuffix;
+        }
+
 		\OCP\Util::emitHook(
 			'\OCA\Files_Sharing\API\Server2Server',
 			'preLoginNameUsedAsUserName',
@@ -288,7 +305,7 @@
 	 */
 	protected function sendEmail($input) {
 		$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
@@ -157,7 +157,7 @@
 						print_unescaped('class="hidden"');
 					} ?>
 					   placeholder="<?php p($l->t('Your email address')); ?>"
-					   autocomplete="on" autocapitalize="none" autocorrect="off" />
+					   autocomplete="on" autocapitalize="none" autocorrect="off" readonly />
 				<span class="icon-checkmark hidden"></span>
 				<span class="icon-error hidden" ></span>
 				<?php if (!$_['displayNameChangeSupported']) { ?>
+13 −15
Original line number Diff line number Diff line
From: Akhil <akhil@e.email>
Date: Tue, 6 Jul 2021 16:20:00 +0530
From: ArnauVP <arnauvp@e.email>
Date: Tue, 23 Mar 2022 11:25:00 +0000
Subject: [PATCH] Remove development notice portion in personal info settings

This patch removes the development notice portion in personal info settings

diff --git ./apps/settings/lib/Settings/ServerDevNotice.php ./apps/settings/lib/Settings/ServerDevNotice-new.php
--- ./apps/settings/lib/Settings/ServerDevNotice.php	2021-07-06 16:16:44.706709243 +0530
+++ ./apps/settings/lib/Settings/ServerDevNotice-new.php	2021-07-06 16:19:56.479687126 +0530
@@ -100,11 +100,12 @@
 	 * @return string the section ID, e.g. 'sharing'
diff --git ./apps/settings/lib/Settings/Personal/ServerDevNotice.php ./apps/settings/lib/Settings/Personal/ServerDevNotice-new.php
--- ./apps/settings/lib/Settings/Personal/ServerDevNotice.php	2022-03-23 12:22:57.000000000 +0100
+++ ./apps/settings/lib/Settings/Personal/ServerDevNotice.php-new	2022-03-23 12:23:25.000000000 +0100
@@ -100,11 +100,7 @@
 	 * @return string|null the section ID, e.g. 'sharing'
 	 */
 	public function getSection() {
 	public function getSection(): ?string {
-		if ($this->registry->delegateHasValidSubscription()) {
+		/*if ($this->registry->delegateHasValidSubscription()) {
 			return null;
 		}
 
-			return null;
-		}
-
-		return 'personal-info';
+        return 'personal-info';*/
+		return null;
 	}

+12 −13
Original line number Diff line number Diff line
From: Akhil <akhil@e.email>
Date: Tue, 22 Jul 2021 18:15:00 +0530
From: ArnauVP <arnauvp@e.email>
Date: Thu, 23 Mar 2022 11:30:00 +0000
Subject: [PATCH] Caches SVGs added via theme

This patch modifies Icons Cacher to check theme for icons and if they exist,
cache them instead of the icons in core or apps directories

diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCacher-new.php
--- ./lib/private/Template/IconsCacher.php	2021-11-16 11:42:40.162071882 +0530
+++ ./lib/private/Template/IconsCacher-new.php	2021-11-16 11:59:07.575908578 +0530
@@ -162,21 +162,29 @@
--- ./lib/private/Template/IconsCacher.php	2022-03-23 12:30:24.000000000 +0100
+++ ./lib/private/Template/IconsCacher-new.php	2022-03-23 12:32:37.000000000 +0100
@@ -161,21 +161,28 @@
 		$color = '';
 		$base = $this->getRoutePrefix() . '/svg/';
 		$cleanUrl = \substr($url, \strlen($base));
@@ -16,7 +16,7 @@ diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCa
 		if (\strpos($url, $base . 'core') === 0) {
 			$cleanUrl = \substr($cleanUrl, \strlen('core'));
 			if (\preg_match('/\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
 				list(,$cleanUrl,$color) = $matches;
 				[,$cleanUrl,$color] = $matches;
-				$location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg';
+				$location = \OC::$SERVERROOT . '/themes/'. $theme . '/core/img/' . $cleanUrl . '.svg';
+                if (!file_exists($location)) {
@@ -25,7 +25,7 @@ diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCa
 			}
 		} elseif (\strpos($url, $base) === 0) {
 			if (\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
 				list(,$app,$cleanUrl, $color) = $matches;
 				[,$app,$cleanUrl, $color] = $matches;
-				$appPath = \OC_App::getAppPath($app);
-				if ($appPath !== false) {
-					$location = $appPath . '/img/' . $cleanUrl . '.svg';
@@ -33,7 +33,6 @@ diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCa
-				if ($app === 'settings') {
-					$location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg';
+				$location = \OC::$SERVERROOT . '/themes/' . $theme . '/apps/' . $app . '/img/' . $cleanUrl . '.svg';
+
+				if (!file_exists($location)) {
+					$appPath = \OC_App::getAppPath($app);
+					if ($appPath !== false) {