From 0762274f4c78c44f494549559d2af9bdf4b3adc8 Mon Sep 17 00:00:00 2001 From: Alexandre R D'Anzi Date: Tue, 9 Apr 2024 00:50:40 +0200 Subject: [PATCH 1/7] Display back to login in error page --- patches/034-display-back-to-login | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 patches/034-display-back-to-login diff --git a/patches/034-display-back-to-login b/patches/034-display-back-to-login new file mode 100644 index 00000000..3aba1b04 --- /dev/null +++ b/patches/034-display-back-to-login @@ -0,0 +1,57 @@ +diff --git a/core/templates/error.php b/core/templates/error.php +index 2e5488ae8d..09fbc1e7c4 100644 +--- a/core/templates/error.php ++++ b/core/templates/error.php +@@ -1,13 +1,17 @@ +
+-

t('Error')) ?>

+- ++

t('Error')) ?>

++ ++ ++ t('Back to login')) ?> ++ +
+diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php +index 0c9fa1ccc0..d137c7f838 100644 +--- a/lib/private/legacy/OC_Template.php ++++ b/lib/private/legacy/OC_Template.php +@@ -279,7 +279,7 @@ class OC_Template extends \OC\Template\Base { + * @param int $statusCode + * @suppress PhanAccessMethodInternal + */ +- public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) { ++ public static function printErrorPage($error_msg, $hint = '', $statusCode = 500, $logoutUrl = null) { + if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { + \OC_App::loadApp('theming'); + } +@@ -293,8 +293,8 @@ class OC_Template extends \OC\Template\Base { + http_response_code($statusCode); + try { + $content = new \OC_Template('', 'error', 'error', false); +- $errors = [['error' => $error_msg, 'hint' => $hint]]; +- $content->assign('errors', $errors); ++ $errors = [['error' => $error_msg, 'hint' => $hint, 'statusCode' => $statusCode]]; ++ $content->assign('logout_url', $logoutUrl != null ? $logoutUrl : OC_User::getLogoutUrl(\OC::$server->getURLGenerator())); + $content->printPage(); + } catch (\Exception $e) { + $logger = \OC::$server->getLogger(); -- GitLab From b1a584024f5dabb334ce91f028a99940707f6e88 Mon Sep 17 00:00:00 2001 From: Alexandre R D'Anzi Date: Fri, 12 Apr 2024 14:43:41 +0200 Subject: [PATCH 2/7] restoring errors in patch --- patches/034-display-back-to-login | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/034-display-back-to-login b/patches/034-display-back-to-login index 3aba1b04..98fb843c 100644 --- a/patches/034-display-back-to-login +++ b/patches/034-display-back-to-login @@ -32,7 +32,7 @@ index 2e5488ae8d..09fbc1e7c4 100644 + diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php -index 0c9fa1ccc0..d137c7f838 100644 +index 0c9fa1ccc0..7f58c6d007 100644 --- a/lib/private/legacy/OC_Template.php +++ b/lib/private/legacy/OC_Template.php @@ -279,7 +279,7 @@ class OC_Template extends \OC\Template\Base { @@ -44,13 +44,13 @@ index 0c9fa1ccc0..d137c7f838 100644 if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { \OC_App::loadApp('theming'); } -@@ -293,8 +293,8 @@ class OC_Template extends \OC\Template\Base { +@@ -293,8 +293,9 @@ class OC_Template extends \OC\Template\Base { http_response_code($statusCode); try { $content = new \OC_Template('', 'error', 'error', false); - $errors = [['error' => $error_msg, 'hint' => $hint]]; -- $content->assign('errors', $errors); + $errors = [['error' => $error_msg, 'hint' => $hint, 'statusCode' => $statusCode]]; + $content->assign('errors', $errors); + $content->assign('logout_url', $logoutUrl != null ? $logoutUrl : OC_User::getLogoutUrl(\OC::$server->getURLGenerator())); $content->printPage(); } catch (\Exception $e) { -- GitLab From 4ac0c42d9de96a4275227b6db5f6e6bbd6afebda Mon Sep 17 00:00:00 2001 From: Alexandre R D'Anzi Date: Fri, 12 Apr 2024 15:05:38 +0200 Subject: [PATCH 3/7] fixing indentation + patch name --- ...-login => 034-display-back-to-login.patch} | 44 +++++++------------ 1 file changed, 16 insertions(+), 28 deletions(-) rename patches/{034-display-back-to-login => 034-display-back-to-login.patch} (57%) diff --git a/patches/034-display-back-to-login b/patches/034-display-back-to-login.patch similarity index 57% rename from patches/034-display-back-to-login rename to patches/034-display-back-to-login.patch index 98fb843c..a52d5ab9 100644 --- a/patches/034-display-back-to-login +++ b/patches/034-display-back-to-login.patch @@ -1,35 +1,23 @@ diff --git a/core/templates/error.php b/core/templates/error.php -index 2e5488ae8d..09fbc1e7c4 100644 +index 2e5488ae8d..d39dc8580b 100644 --- a/core/templates/error.php +++ b/core/templates/error.php -@@ -1,13 +1,17 @@ +@@ -1,4 +1,5 @@
--

t('Error')) ?>

--
    -- --
  • --

    -- --

    -- --
  • -- --
-+

t('Error')) ?>

-+
    -+ -+
  • -+

    -+ -+

    -+ -+
  • -+ -+ -+
-+ -+ t('Back to login')) ?> -+ ++ +

t('Error')) ?>

+
    + +@@ -8,6 +9,10 @@ +

    + + ++ + +
++ ++ t('Back to login')) ?> ++
diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php index 0c9fa1ccc0..7f58c6d007 100644 -- GitLab From 7d7f83f7120e5f36066f2e1ae37bf0cd37be18e7 Mon Sep 17 00:00:00 2001 From: Alexandre R D'Anzi Date: Mon, 15 Apr 2024 15:38:48 +0200 Subject: [PATCH 4/7] atomic patch files + apply patches --- Dockerfile | 2 ++ ...034-display-back-to-login-error-page.patch | 21 +++++++++++++++++++ ...5-display-back-to-login-oc_template.patch} | 21 ------------------- 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 patches/034-display-back-to-login-error-page.patch rename patches/{034-display-back-to-login.patch => 035-display-back-to-login-oc_template.patch} (64%) diff --git a/Dockerfile b/Dockerfile index b8b7abe7..22052209 100644 --- a/Dockerfile +++ b/Dockerfile @@ -220,6 +220,8 @@ RUN patch -u ${BASE_DIR}/apps/dav/lib/Connector/Sabre/Principal.php -i ${TMP_PAT RUN patch -u ${BASE_DIR}/apps/dav/lib/HookManager.php -i ${TMP_PATCH_DIR}/028-default-task-calendar.patch RUN patch -u ${BASE_DIR}/apps/provisioning_api/lib/Controller/UsersController.php -i ${TMP_PATCH_DIR}/029-restrict-user-to-change-primary-email.patch RUN patch -u ${BASE_DIR}/lib/private/Security/VerificationToken/VerificationToken.php -i ${TMP_PATCH_DIR}/033-verification-token-private.patch +RUN patch -u ${BASE_DIR}/core/templates/error.php -i ${TMP_PATCH_DIR}/034-display-back-to-login-error-page.patch +RUN patch -u ${BASE_DIR}/lib/private/legacy/OC_Template.php -i ${TMP_PATCH_DIR}/035-display-back-to-login-oc_template.patch RUN rm -rf ${TMP_PATCH_DIR} RUN curl -fsSL -o ldap_write_support.tar.gz \ diff --git a/patches/034-display-back-to-login-error-page.patch b/patches/034-display-back-to-login-error-page.patch new file mode 100644 index 00000000..3394ed20 --- /dev/null +++ b/patches/034-display-back-to-login-error-page.patch @@ -0,0 +1,21 @@ +diff --git a/core/templates/error.php b/core/templates/error.php +index 2e5488ae8d..d39dc8580b 100644 +--- a/core/templates/error.php ++++ b/core/templates/error.php +@@ -1,4 +1,5 @@ +
++ +

t('Error')) ?>

+
    + +@@ -8,6 +9,10 @@ +

    + + ++ + +
++ ++ t('Back to login')) ?> ++ +
diff --git a/patches/034-display-back-to-login.patch b/patches/035-display-back-to-login-oc_template.patch similarity index 64% rename from patches/034-display-back-to-login.patch rename to patches/035-display-back-to-login-oc_template.patch index a52d5ab9..7cd89368 100644 --- a/patches/034-display-back-to-login.patch +++ b/patches/035-display-back-to-login-oc_template.patch @@ -1,24 +1,3 @@ -diff --git a/core/templates/error.php b/core/templates/error.php -index 2e5488ae8d..d39dc8580b 100644 ---- a/core/templates/error.php -+++ b/core/templates/error.php -@@ -1,4 +1,5 @@ -
-+ -

t('Error')) ?>

-
    - -@@ -8,6 +9,10 @@ -

    - - -+ - -
-+ -+ t('Back to login')) ?> -+ -
diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php index 0c9fa1ccc0..7f58c6d007 100644 --- a/lib/private/legacy/OC_Template.php -- GitLab From d883597a4a957254b448ebc9d470a7d27b337afa Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 16 Apr 2024 15:07:04 +0000 Subject: [PATCH 5/7] Apply 2 suggestion(s) to 1 file(s) --- patches/035-display-back-to-login-oc_template.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/035-display-back-to-login-oc_template.patch b/patches/035-display-back-to-login-oc_template.patch index 7cd89368..4b3b9f62 100644 --- a/patches/035-display-back-to-login-oc_template.patch +++ b/patches/035-display-back-to-login-oc_template.patch @@ -1,7 +1,7 @@ diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php index 0c9fa1ccc0..7f58c6d007 100644 ---- a/lib/private/legacy/OC_Template.php -+++ b/lib/private/legacy/OC_Template.php +--- ./lib/private/legacy/OC_Template.php ++++ ./lib/private/legacy/OC_Template-new.php @@ -279,7 +279,7 @@ class OC_Template extends \OC\Template\Base { * @param int $statusCode * @suppress PhanAccessMethodInternal -- GitLab From 43ce78c12b1111fffbb703d161fd2bed7d7f5a8d Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 16 Apr 2024 15:08:31 +0000 Subject: [PATCH 6/7] Apply 2 suggestion(s) to 1 file(s) --- patches/034-display-back-to-login-error-page.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/034-display-back-to-login-error-page.patch b/patches/034-display-back-to-login-error-page.patch index 3394ed20..ae4f6cda 100644 --- a/patches/034-display-back-to-login-error-page.patch +++ b/patches/034-display-back-to-login-error-page.patch @@ -1,7 +1,7 @@ diff --git a/core/templates/error.php b/core/templates/error.php index 2e5488ae8d..d39dc8580b 100644 ---- a/core/templates/error.php -+++ b/core/templates/error.php +--- ./core/templates/error.php ++++ ./core/templates/error-new.php @@ -1,4 +1,5 @@
+ -- GitLab From c72db14b56e606ca77c4116d09f68bb18d0fb965 Mon Sep 17 00:00:00 2001 From: Alexandre R D'Anzi Date: Tue, 16 Apr 2024 23:11:32 +0200 Subject: [PATCH 7/7] back to single file patch + comment within patch + move logic to OC_template instead of error page --- Dockerfile | 3 +- ...034-display-back-to-login-error-page.patch | 21 ----------- ...35-display-back-to-login-oc_template.patch | 24 ------------- patches/035-display-back-to-login.patch | 36 +++++++++++++++++++ 4 files changed, 37 insertions(+), 47 deletions(-) delete mode 100644 patches/034-display-back-to-login-error-page.patch delete mode 100644 patches/035-display-back-to-login-oc_template.patch create mode 100644 patches/035-display-back-to-login.patch diff --git a/Dockerfile b/Dockerfile index 22052209..cdb5caac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -220,8 +220,7 @@ RUN patch -u ${BASE_DIR}/apps/dav/lib/Connector/Sabre/Principal.php -i ${TMP_PAT RUN patch -u ${BASE_DIR}/apps/dav/lib/HookManager.php -i ${TMP_PATCH_DIR}/028-default-task-calendar.patch RUN patch -u ${BASE_DIR}/apps/provisioning_api/lib/Controller/UsersController.php -i ${TMP_PATCH_DIR}/029-restrict-user-to-change-primary-email.patch RUN patch -u ${BASE_DIR}/lib/private/Security/VerificationToken/VerificationToken.php -i ${TMP_PATCH_DIR}/033-verification-token-private.patch -RUN patch -u ${BASE_DIR}/core/templates/error.php -i ${TMP_PATCH_DIR}/034-display-back-to-login-error-page.patch -RUN patch -u ${BASE_DIR}/lib/private/legacy/OC_Template.php -i ${TMP_PATCH_DIR}/035-display-back-to-login-oc_template.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/035-display-back-to-login.patch RUN rm -rf ${TMP_PATCH_DIR} RUN curl -fsSL -o ldap_write_support.tar.gz \ diff --git a/patches/034-display-back-to-login-error-page.patch b/patches/034-display-back-to-login-error-page.patch deleted file mode 100644 index ae4f6cda..00000000 --- a/patches/034-display-back-to-login-error-page.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/core/templates/error.php b/core/templates/error.php -index 2e5488ae8d..d39dc8580b 100644 ---- ./core/templates/error.php -+++ ./core/templates/error-new.php -@@ -1,4 +1,5 @@ -
-+ -

t('Error')) ?>

-
    - -@@ -8,6 +9,10 @@ -

    - - -+ - -
-+ -+ t('Back to login')) ?> -+ -
diff --git a/patches/035-display-back-to-login-oc_template.patch b/patches/035-display-back-to-login-oc_template.patch deleted file mode 100644 index 4b3b9f62..00000000 --- a/patches/035-display-back-to-login-oc_template.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php -index 0c9fa1ccc0..7f58c6d007 100644 ---- ./lib/private/legacy/OC_Template.php -+++ ./lib/private/legacy/OC_Template-new.php -@@ -279,7 +279,7 @@ class OC_Template extends \OC\Template\Base { - * @param int $statusCode - * @suppress PhanAccessMethodInternal - */ -- public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) { -+ public static function printErrorPage($error_msg, $hint = '', $statusCode = 500, $logoutUrl = null) { - if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { - \OC_App::loadApp('theming'); - } -@@ -293,8 +293,9 @@ class OC_Template extends \OC\Template\Base { - http_response_code($statusCode); - try { - $content = new \OC_Template('', 'error', 'error', false); -- $errors = [['error' => $error_msg, 'hint' => $hint]]; -+ $errors = [['error' => $error_msg, 'hint' => $hint, 'statusCode' => $statusCode]]; - $content->assign('errors', $errors); -+ $content->assign('logout_url', $logoutUrl != null ? $logoutUrl : OC_User::getLogoutUrl(\OC::$server->getURLGenerator())); - $content->printPage(); - } catch (\Exception $e) { - $logger = \OC::$server->getLogger(); diff --git a/patches/035-display-back-to-login.patch b/patches/035-display-back-to-login.patch new file mode 100644 index 00000000..5078e214 --- /dev/null +++ b/patches/035-display-back-to-login.patch @@ -0,0 +1,36 @@ +Subject: [PATCH] This patch display a back to login link in error page when encountering a 401 HTTP Error code + +diff --git a/core/templates/error.php b/core/templates/error.php +index 2e5488ae8d..72c58e3bcf 100644 +--- core/templates/error.php ++++ core/templates/error.php +@@ -10,4 +10,7 @@ + + + ++ ++ t('Back to login')) ?> ++ +
+diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php +index 0c9fa1ccc0..6792f2268e 100644 +--- lib/private/legacy/OC_Template.php ++++ lib/private/legacy/OC_Template.php +@@ -279,7 +279,7 @@ class OC_Template extends \OC\Template\Base { + * @param int $statusCode + * @suppress PhanAccessMethodInternal + */ +- public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) { ++ public static function printErrorPage($error_msg, $hint = '', $statusCode = 500, $logoutUrl = null) { + if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { + \OC_App::loadApp('theming'); + } +@@ -295,6 +295,8 @@ class OC_Template extends \OC\Template\Base { + $content = new \OC_Template('', 'error', 'error', false); + $errors = [['error' => $error_msg, 'hint' => $hint]]; + $content->assign('errors', $errors); ++ if($statusCode === 401) ++ $content->assign('logout_url', $logoutUrl != null ? $logoutUrl : OC_User::getLogoutUrl(\OC::$server->getURLGenerator())); + $content->printPage(); + } catch (\Exception $e) { + $logger = \OC::$server->getLogger(); -- GitLab