Skip to content

Commit

Permalink
Merge pull request #35804 from nextcloud/backport/34629/stable24
Browse files Browse the repository at this point in the history
[stable24] Fix case sensitivity of email when saving settings
  • Loading branch information
artonge authored Dec 19, 2022
2 parents 05d96e0 + 28aaa5a commit 8dc6516
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/settings/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
10 changes: 9 additions & 1 deletion apps/settings/tests/Controller/UsersControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
],

];
}
Expand Down

0 comments on commit 8dc6516

Please sign in to comment.