diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 7c543508496a3..217abf0e156be 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -491,7 +491,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()) { diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php index 9ad81148ef1e2..e90f34d3efd14 100644 --- a/apps/settings/tests/Controller/UsersControllerTest.php +++ b/apps/settings/tests/Controller/UsersControllerTest.php @@ -649,7 +649,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 { @@ -745,6 +745,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 + ], ]; }