Skip to content

Commit a6c11af

Browse files
authored
Merge pull request #35803 from nextcloud/backport/34629/stable25
[stable25] Fix case sensitivity of email when saving settings
2 parents 1efbbd8 + bf4f0d3 commit a6c11af

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

apps/settings/lib/Controller/UsersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ protected function saveUserSettings(IAccount $userAccount): void {
484484

485485
$oldEmailAddress = $userAccount->getUser()->getSystemEMailAddress();
486486
$oldEmailAddress = strtolower((string)$oldEmailAddress);
487-
if ($oldEmailAddress !== $userAccount->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue()) {
487+
if ($oldEmailAddress !== strtolower($userAccount->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue())) {
488488
// this is the only permission a backend provides and is also used
489489
// for the permission of setting a email address
490490
if (!$userAccount->getUser()->canChangeDisplayName()) {

apps/settings/tests/Controller/UsersControllerTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public function testSaveUserSettings($data,
624624
$user->method('getSystemEMailAddress')->willReturn($oldEmailAddress);
625625
$user->method('canChangeDisplayName')->willReturn(true);
626626

627-
if ($data[IAccountManager::PROPERTY_EMAIL]['value'] === $oldEmailAddress ||
627+
if (strtolower($data[IAccountManager::PROPERTY_EMAIL]['value']) === strtolower($oldEmailAddress) ||
628628
($oldEmailAddress === null && $data[IAccountManager::PROPERTY_EMAIL]['value'] === '')) {
629629
$user->expects($this->never())->method('setSystemEMailAddress');
630630
} else {
@@ -720,6 +720,14 @@ public function dataTestSaveUserSettings() {
720720
'john@example.com',
721721
null
722722
],
723+
[
724+
[
725+
IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'],
726+
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'],
727+
],
728+
'JOHN@example.com',
729+
null
730+
],
723731

724732
];
725733
}

0 commit comments

Comments
 (0)