Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2ba56b5
Fix summary footer position and text contrast
jancborchardt Apr 12, 2021
6be8894
Improve focus feedback for file list actions
jancborchardt Apr 13, 2021
5792250
Add proper labels for personal settings privacy toggles
jancborchardt Apr 13, 2021
73cf806
Fix screenreader label of search icon
jancborchardt Apr 13, 2021
0a3875e
Fix missing label of grid view toggle
jancborchardt Apr 13, 2021
199f736
Fix missing label of Files navigation sublist toggles
jancborchardt Apr 13, 2021
9bb2e8d
Fix accessibility of profile picture section
jancborchardt Apr 15, 2021
b276593
Fix accessibility of federation menu privacy buttons
jancborchardt Apr 15, 2021
f4171c9
Fix avatar actions
nickvergessen Jun 15, 2021
4fbb9b2
Use constants from interface rather than class
danxuliu Jan 29, 2021
2eeac35
Extract default test data to a helper getter
danxuliu Jan 29, 2021
36fa740
Change default test data to values less similar to empty values
danxuliu Jan 29, 2021
7ed78d2
Add more unit tests for setting user settings
danxuliu Jan 29, 2021
6865d51
Respect additional user settings not covered by the controller
danxuliu Jan 29, 2021
ae7eca8
Fix TypeError when "email" is not given in the controller request
danxuliu Jan 31, 2021
44c870a
Fix deleting properties of user settings when not given explicitly
danxuliu Jan 31, 2021
491c031
Add integration tests for searching users in contacts menu
danxuliu Jan 31, 2021
3ae1ec4
Guard against null phone number value
danxuliu Jan 31, 2021
43a9879
Fix active scope not visible in the menu if excluded
danxuliu Feb 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Respect additional user settings not covered by the controller
"AccountManager::updateUser()" wipes previous user data with whichever
user data is given (except for some adjustments, like resetting the
verified status when needed). As the controller overrode the properties
those properties would lose some of their attributes even if they are
not affected by the changes made by the controller. Now the controller
only modifies the attributes set ("value" and "scope") to prevent that.

Note that with this change the controller no longer removes the
"verified" status, but this is not a problem because, as mentioned,
"AccountManager::updateUser()" resets them when needed (for example,
when the value of the website property changes).

This change is a previous step to fix overwritting properties with null
values, and it will prevent the controller from making unexpected
changes if more attributes are added in the future.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Jul 2, 2021
commit 6865d518697b59dffe6b1c825f5a082fa9852974
20 changes: 13 additions & 7 deletions apps/settings/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,21 @@ public function setUserSettings(?string $avatarScope = null,

$data = $this->accountManager->getUser($user);
$beforeData = $data;
$data[IAccountManager::PROPERTY_AVATAR] = ['scope' => $avatarScope];
$data[IAccountManager::PROPERTY_AVATAR]['scope'] = $avatarScope;
if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
$data[IAccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope];
$data[IAccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope];
$data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] = $displayname;
$data[IAccountManager::PROPERTY_DISPLAYNAME]['scope'] = $displaynameScope;
$data[IAccountManager::PROPERTY_EMAIL]['value'] = $email;
$data[IAccountManager::PROPERTY_EMAIL]['scope'] = $emailScope;
}
$data[IAccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope];
$data[IAccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope];
$data[IAccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope];
$data[IAccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope];
$data[IAccountManager::PROPERTY_WEBSITE]['value'] = $website;
$data[IAccountManager::PROPERTY_WEBSITE]['scope'] = $websiteScope;
$data[IAccountManager::PROPERTY_ADDRESS]['value'] = $address;
$data[IAccountManager::PROPERTY_ADDRESS]['scope'] = $addressScope;
$data[IAccountManager::PROPERTY_PHONE]['value'] = $phone;
$data[IAccountManager::PROPERTY_PHONE]['scope'] = $phoneScope;
$data[IAccountManager::PROPERTY_TWITTER]['value'] = $twitter;
$data[IAccountManager::PROPERTY_TWITTER]['scope'] = $twitterScope;

try {
$data = $this->saveUserSettings($user, $data);
Expand Down
10 changes: 0 additions & 10 deletions apps/settings/tests/Controller/UsersControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,12 @@ public function testSetUserSettingsWhenUserDisplayNameChangeNotAllowed() {
$expectedProperties[IAccountManager::PROPERTY_AVATAR]['scope'] = $avatarScope;
$expectedProperties[IAccountManager::PROPERTY_PHONE]['value'] = $phone;
$expectedProperties[IAccountManager::PROPERTY_PHONE]['scope'] = $phoneScope;
unset($expectedProperties[IAccountManager::PROPERTY_PHONE]['verified']);
$expectedProperties[IAccountManager::PROPERTY_WEBSITE]['value'] = $website;
$expectedProperties[IAccountManager::PROPERTY_WEBSITE]['scope'] = $websiteScope;
unset($expectedProperties[IAccountManager::PROPERTY_WEBSITE]['verified']);
$expectedProperties[IAccountManager::PROPERTY_ADDRESS]['value'] = $address;
$expectedProperties[IAccountManager::PROPERTY_ADDRESS]['scope'] = $addressScope;
unset($expectedProperties[IAccountManager::PROPERTY_ADDRESS]['verified']);
$expectedProperties[IAccountManager::PROPERTY_TWITTER]['value'] = $twitter;
$expectedProperties[IAccountManager::PROPERTY_TWITTER]['scope'] = $twitterScope;
unset($expectedProperties[IAccountManager::PROPERTY_TWITTER]['verified']);

$this->mailer->expects($this->once())->method('validateMailAddress')
->willReturn(true);
Expand Down Expand Up @@ -405,22 +401,16 @@ public function testSetUserSettingsWhenFederatedFilesharingNotEnabled() {
$expectedProperties[IAccountManager::PROPERTY_AVATAR]['scope'] = $avatarScope;
$expectedProperties[IAccountManager::PROPERTY_DISPLAYNAME]['value'] = $displayName;
$expectedProperties[IAccountManager::PROPERTY_DISPLAYNAME]['scope'] = $displayNameScope;
unset($expectedProperties[IAccountManager::PROPERTY_DISPLAYNAME]['verified']);
$expectedProperties[IAccountManager::PROPERTY_EMAIL]['value'] = $email;
$expectedProperties[IAccountManager::PROPERTY_EMAIL]['scope'] = $emailScope;
unset($expectedProperties[IAccountManager::PROPERTY_EMAIL]['verified']);
$expectedProperties[IAccountManager::PROPERTY_PHONE]['value'] = $phone;
$expectedProperties[IAccountManager::PROPERTY_PHONE]['scope'] = $phoneScope;
unset($expectedProperties[IAccountManager::PROPERTY_PHONE]['verified']);
$expectedProperties[IAccountManager::PROPERTY_WEBSITE]['value'] = $website;
$expectedProperties[IAccountManager::PROPERTY_WEBSITE]['scope'] = $websiteScope;
unset($expectedProperties[IAccountManager::PROPERTY_WEBSITE]['verified']);
$expectedProperties[IAccountManager::PROPERTY_ADDRESS]['value'] = $address;
$expectedProperties[IAccountManager::PROPERTY_ADDRESS]['scope'] = $addressScope;
unset($expectedProperties[IAccountManager::PROPERTY_ADDRESS]['verified']);
$expectedProperties[IAccountManager::PROPERTY_TWITTER]['value'] = $twitter;
$expectedProperties[IAccountManager::PROPERTY_TWITTER]['scope'] = $twitterScope;
unset($expectedProperties[IAccountManager::PROPERTY_TWITTER]['verified']);

$this->mailer->expects($this->once())->method('validateMailAddress')
->willReturn(true);
Expand Down