diff --git a/patches/002-login-without-domain.patch b/patches/002-login-without-domain.patch index 0d61eb88598c316f61acba7333c18750080c76d3..aa1f15e6448343196a60c1c278071c1f0d25df73 100644 --- a/patches/002-login-without-domain.patch +++ b/patches/002-login-without-domain.patch @@ -7,35 +7,46 @@ This patch auto append the domain handled by nc, configured in env var. only the admin user (also configured in env var) will not have his login appended with a @domain suffix diff --git ./core/Controller/LoginController.php ./core/Controller/LoginController-new.php ---- ./core/Controller/LoginController.php 2023-04-21 15:08:54.979407062 +0530 -+++ ./core/Controller/LoginController-new.php 2023-04-21 15:16:48.582366408 +0530 -@@ -318,6 +318,26 @@ - $this->l10n->t('Please try again') +--- ./core/Controller/LoginController.php 2024-04-26 15:08:54.979407062 +0530 ++++ ./core/Controller/LoginController-new.php 2024-04-26 15:16:48.582366408 +0530 +@@ -315,7 +315,28 @@ + self::LOGIN_MSG_CSRFCHECKFAILED ); } + $user = trim($user); -+ $user = mb_strtolower($user, 'UTF-8'); -+ $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); -+ $legacyDomainSuffix = !empty($legacyDomain) ? '@' . $legacyDomain : ''; -+ $mainDomain = $this->config->getSystemValue('main_domain', ''); -+ $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; -+ $admin_username = $_ENV["NEXTCLOUD_ADMIN_USER"]; -+ $is_admin = strcmp($user, $admin_username) === 0; -+ ++ $user = mb_strtolower($user, 'UTF-8'); ++ $actualUser = $user; ++ $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); ++ $legacyDomainSuffix = !empty($legacyDomain) ? '@' . $legacyDomain : ''; ++ $mainDomain = $this->config->getSystemValue('main_domain', ''); ++ $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; ++ $admin_username = $_ENV["NEXTCLOUD_ADMIN_USER"]; ++ $is_admin = strcmp($user, $admin_username) === 0; + + if (!$is_admin && str_ends_with($user, $legacyDomainSuffix)) { -+ $user = str_replace($legacyDomainSuffix, '', $user); -+ } ++ $user = str_replace($legacyDomainSuffix, '', $user); ++ } + -+ if (!$is_admin && str_ends_with($user, $mainDomainSuffix)) { -+ $user = str_replace($mainDomainSuffix, '', $user); -+ } ++ if (!$is_admin && str_ends_with($user, $mainDomainSuffix)) { ++ $user = str_replace($mainDomainSuffix, '', $user); ++ } ++ ++ if (!$this->userManager->userExists($user)) { ++ $user = $user . $legacyDomainSuffix; ++ } + -+ if (!$this->userManager->userExists($user)) { -+ $user = $user . $legacyDomainSuffix; -+ } - $data = new LoginData( $this->request, + trim($user), +@@ -328,7 +349,7 @@ + if (!$result->isSuccess()) { + return $this->createLoginFailedResponse( + $data->getUsername(), +- $user, ++ $actualUser, + $redirect_url, + $result->getErrorMessage() + ); --- ./core/Controller/WebAuthnController.php 2023-04-21 15:18:58.813220092 +0530 +++ ./core/Controller/WebAuthnController-new.php 2023-04-21 15:24:40.036538414 +0530 @@ -66,6 +66,27 @@