From ff6279edab216415d2f33e92811aeb518b435b97 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 17 Oct 2022 12:41:38 +0200 Subject: [PATCH 1/2] Fix case sensitivity of email when saving settings Otherwise we detect a email change all the time and since email are immutable in ldap this prevent updating other fields. Related: https://github.com/nextcloud/server/pull/33813 Signed-off-by: Carl Schwan --- apps/settings/lib/Controller/UsersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 6be93d6a3a03d..3a43442bda4cf 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -484,7 +484,7 @@ protected function saveUserSettings(IAccount $userAccount): void { $oldEmailAddress = $userAccount->getUser()->getSystemEMailAddress(); $oldEmailAddress = strtolower((string)$oldEmailAddress); - if ($oldEmailAddress !== $userAccount->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue()) { + if ($oldEmailAddress !== strtolower($userAccount->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue())) { // this is the only permission a backend provides and is also used // for the permission of setting a email address if (!$userAccount->getUser()->canChangeDisplayName()) { From 28aaa5aefcfaa0d3e4058172898bff6100a3e3e4 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 16 Dec 2022 17:47:18 +0100 Subject: [PATCH 2/2] Add unit test for case insensitive email saving Signed-off-by: Vincent Petry --- apps/settings/tests/Controller/UsersControllerTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php index 797fa1621fa82..ba7d9689130c8 100644 --- a/apps/settings/tests/Controller/UsersControllerTest.php +++ b/apps/settings/tests/Controller/UsersControllerTest.php @@ -624,7 +624,7 @@ public function testSaveUserSettings($data, $user->method('getSystemEMailAddress')->willReturn($oldEmailAddress); $user->method('canChangeDisplayName')->willReturn(true); - if ($data[IAccountManager::PROPERTY_EMAIL]['value'] === $oldEmailAddress || + if (strtolower($data[IAccountManager::PROPERTY_EMAIL]['value']) === strtolower($oldEmailAddress) || ($oldEmailAddress === null && $data[IAccountManager::PROPERTY_EMAIL]['value'] === '')) { $user->expects($this->never())->method('setSystemEMailAddress'); } else { @@ -720,6 +720,14 @@ public function dataTestSaveUserSettings() { 'john@example.com', null ], + [ + [ + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + ], + 'JOHN@example.com', + null + ], ]; }