From e7939936853b5d564c6445e3b2c4ebf25bb56a1d Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 14 Sep 2023 11:20:35 -0700 Subject: [PATCH 1/7] addec condition --- appinfo/info.xml | 2 +- lib/Controller/UserController.php | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index d72581ef..7ee2a930 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -10,7 +10,7 @@ - 3.4.0 + 3.4.1 agpl Murena SAS EcloudAccounts diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index d5bf3651..370ab44a 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -50,10 +50,17 @@ class UserController extends ApiController { } // To check for old accounts - $mailDomain = $this->config->getSystemValue('mail_domain'); - $mailDomainSuffix = !empty($mailDomain) ? '@' . $mailDomain : ''; - if (!$exists && stristr($uid, $mailDomainSuffix) === false) { - $exists = $this->userService->userExists($uid . $mailDomainSuffix); + $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); + $legacyDomainSuffix = !empty($legacyDomain) ? '@' . $legacyDomain : ''; + + $mainDomain = $this->config->getSystemValue('main_domain'); + $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; + + if (!$exists && str_ends_with($uid, $legacyDomainSuffix)) { + $exists = $this->userService->userExists($uid . $legacyDomainSuffix); + } + if (!$exists && str_ends_with($uid, $mainDomainSuffix)) { + $exists = $this->userService->userExists($uid . $mainDomainSuffix); } $response->setData($exists); -- GitLab From 2835aa37981500babe7d5bfdb62ecb6ae0f1de7c Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 14 Sep 2023 11:31:25 -0700 Subject: [PATCH 2/7] added str_replace --- lib/Controller/UserController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 370ab44a..da49a8aa 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -57,9 +57,11 @@ class UserController extends ApiController { $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; if (!$exists && str_ends_with($uid, $legacyDomainSuffix)) { + $uid = str_replace($legacyDomainSuffix, '', $uid); $exists = $this->userService->userExists($uid . $legacyDomainSuffix); } if (!$exists && str_ends_with($uid, $mainDomainSuffix)) { + $uid = str_replace($mainDomainSuffix, '', $uid); $exists = $this->userService->userExists($uid . $mainDomainSuffix); } -- GitLab From 219f2bb2e4ab89cee88b6a559cfdcf520d8551d0 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 14 Sep 2023 11:40:43 -0700 Subject: [PATCH 3/7] added uid --- lib/Controller/UserController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index da49a8aa..fddf8e96 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -56,15 +56,13 @@ class UserController extends ApiController { $mainDomain = $this->config->getSystemValue('main_domain'); $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; - if (!$exists && str_ends_with($uid, $legacyDomainSuffix)) { + if (str_ends_with($uid, $legacyDomainSuffix)) { $uid = str_replace($legacyDomainSuffix, '', $uid); - $exists = $this->userService->userExists($uid . $legacyDomainSuffix); } - if (!$exists && str_ends_with($uid, $mainDomainSuffix)) { + if (str_ends_with($uid, $mainDomainSuffix)) { $uid = str_replace($mainDomainSuffix, '', $uid); - $exists = $this->userService->userExists($uid . $mainDomainSuffix); } - + $exists = $this->userService->userExists($uid); $response->setData($exists); return $response; } -- GitLab From b3a02d774b017a6668a1ab37c5198f8221b9e61a Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 14 Sep 2023 11:44:13 -0700 Subject: [PATCH 4/7] added uid --- lib/Controller/UserController.php | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index fddf8e96..2221fc50 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -43,26 +43,25 @@ class UserController extends ApiController { return $response; } - $exists = false; - - if ($this->userService->userExists($uid)) { - $exists = true; - } - - // To check for old accounts - $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); - $legacyDomainSuffix = !empty($legacyDomain) ? '@' . $legacyDomain : ''; + $exists = $this->userService->userExists($uid); - $mainDomain = $this->config->getSystemValue('main_domain'); - $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; - - if (str_ends_with($uid, $legacyDomainSuffix)) { - $uid = str_replace($legacyDomainSuffix, '', $uid); - } - if (str_ends_with($uid, $mainDomainSuffix)) { - $uid = str_replace($mainDomainSuffix, '', $uid); + if (!$exists) { + $uid = trim($uid); + $uid = mb_strtolower($uid, 'UTF-8'); + $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); + $legacyDomainSuffix = !empty($legacyDomain) ? '@' . $legacyDomain : ''; + + $mainDomain = $this->config->getSystemValue('main_domain'); + $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; + + if (str_ends_with($uid, $legacyDomainSuffix)) { + $uid = str_replace($legacyDomainSuffix, '', $uid); + } + if (str_ends_with($uid, $mainDomainSuffix)) { + $uid = str_replace($mainDomainSuffix, '', $uid); + } + $exists = $this->userService->userExists($uid); } - $exists = $this->userService->userExists($uid); $response->setData($exists); return $response; } -- GitLab From 2a14745b28a34aff3b6393452589da12cca4cd56 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 14 Sep 2023 11:49:49 -0700 Subject: [PATCH 5/7] refactored code --- lib/Controller/UserController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 2221fc50..03368417 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -61,6 +61,12 @@ class UserController extends ApiController { $uid = str_replace($mainDomainSuffix, '', $uid); } $exists = $this->userService->userExists($uid); + if(!$exists) { + $exists = $this->userService->userExists($uid . $mainDomainSuffix); + } + if(!$exists) { + $exists = $this->userService->userExists($uid . $legacyDomainSuffix); + } } $response->setData($exists); return $response; -- GitLab From 5bb91a09bd6fd151269d5859a648dbefff4c2b79 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 14 Sep 2023 12:06:16 -0700 Subject: [PATCH 6/7] added function if userexists --- lib/Controller/UserController.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 03368417..2be689c3 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -43,6 +43,11 @@ class UserController extends ApiController { return $response; } + $exists = $this->checkUserExists($uid); + $response->setData($exists); + return $response; + } + public function checkUserExists(string $uid) : bool { $exists = $this->userService->userExists($uid); if (!$exists) { @@ -68,10 +73,8 @@ class UserController extends ApiController { $exists = $this->userService->userExists($uid . $legacyDomainSuffix); } } - $response->setData($exists); - return $response; + return $exists; } - /** * @CORS * @PublicPage @@ -85,7 +88,7 @@ class UserController extends ApiController { return $response; } - if (!$this->userService->userExists($uid)) { + if (!$this->checkUserExists($uid)) { $response->setStatus(404); return $response; } -- GitLab From e820613f5eae0ce23ad171afebd2e27e03062974 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 15 Sep 2023 01:52:51 -0700 Subject: [PATCH 7/7] rolledback --- lib/Controller/UserController.php | 45 +++++++++++-------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 2be689c3..96bf75a3 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -43,38 +43,23 @@ class UserController extends ApiController { return $response; } - $exists = $this->checkUserExists($uid); + $exists = false; + + if ($this->userService->userExists($uid)) { + $exists = true; + } + + // To check for old accounts + $legacyDomain = $this->config->getSystemValue('legacy_domain'); + $legacyDomainSuffix = !empty($legacyDomain) ? '@' . $legacyDomain : ''; + if (!$exists && stristr($uid, $legacyDomainSuffix) === false) { + $exists = $this->userService->userExists($uid . $legacyDomainSuffix); + } + $response->setData($exists); return $response; } - public function checkUserExists(string $uid) : bool { - $exists = $this->userService->userExists($uid); - - if (!$exists) { - $uid = trim($uid); - $uid = mb_strtolower($uid, 'UTF-8'); - $legacyDomain = $this->config->getSystemValue('legacy_domain', ''); - $legacyDomainSuffix = !empty($legacyDomain) ? '@' . $legacyDomain : ''; - - $mainDomain = $this->config->getSystemValue('main_domain'); - $mainDomainSuffix = !empty($mainDomain) ? '@' . $mainDomain : ''; - - if (str_ends_with($uid, $legacyDomainSuffix)) { - $uid = str_replace($legacyDomainSuffix, '', $uid); - } - if (str_ends_with($uid, $mainDomainSuffix)) { - $uid = str_replace($mainDomainSuffix, '', $uid); - } - $exists = $this->userService->userExists($uid); - if(!$exists) { - $exists = $this->userService->userExists($uid . $mainDomainSuffix); - } - if(!$exists) { - $exists = $this->userService->userExists($uid . $legacyDomainSuffix); - } - } - return $exists; - } + /** * @CORS * @PublicPage @@ -88,7 +73,7 @@ class UserController extends ApiController { return $response; } - if (!$this->checkUserExists($uid)) { + if (!$this->userService->userExists($uid)) { $response->setStatus(404); return $response; } -- GitLab