-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix warning when resetting user's password with masterkey encryption #36523
Conversation
62a0cde
to
5d08d0a
Compare
5d08d0a
to
ba596e8
Compare
Unit test expectations also need adjusting: https://drone.owncloud.com/owncloud/core/21714/13/9 |
Codecov Report
@@ Coverage Diff @@
## master #36523 +/- ##
============================================
- Coverage 64.67% 64.67% -0.01%
+ Complexity 19099 19098 -1
============================================
Files 1268 1268
Lines 74695 74693 -2
Branches 1320 1320
============================================
- Hits 48309 48307 -2
Misses 25998 25998
Partials 388 388
Continue to review full report at Codecov.
|
@@ -186,6 +186,9 @@ private function formatUserForIndex(IUser $user, array $userGroups = null) { | |||
// user also has recovery mode enabled | |||
$restorePossible = true; | |||
} | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of if's and else would bring down the readability. How about changing this code to:
if ($this->isRestoreEnabled) {
$recoveryMode = $this->config->getUserValue($user->getUID(), 'encryption', 'recoveryEnabled', '0');
// method call inside empty is possible with PHP 5.5+
$recoveryModeEnabled = !empty($recoveryMode);
if ($recoveryModeEnabled) {
// user also has recovery mode enabled
$restorePossible = true;
}
} else {
$restorePossible = true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sharidas thanks for the suggestion!
I guess we can indeed get rid of the if (this->isEncryptionAppEnabled)
condition since if ($this->isRestoreEnabled)
is basically already performing the same check. This will help us to have better code readability.
Got also rid of any reference to isEncryptionAppEnabled
from code.
79ae211
to
30fb6cb
Compare
30fb6cb
to
0c6fcf8
Compare
There was a semi colon added in the proposesd change, due to which the tests were failing. I have removed the semi colon and now the tests should pass. |
0c6fcf8
to
9916188
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the code looks good to me. I have not tested this. If it works as expected, then Ok from my side.
Fix unit test when restorePossible is set for masterkey encryption. Signed-off-by: Sujith H <[email protected]>
9916188
to
6e31d51
Compare
I rebased just now to make sure that CI is still good for this. @micbar is this to be released? |
Tests done
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
thanks @phil-davis @sharidas @micbar |
Description
Suppress warning when resetting user's password over the Users management page with masterkey encryption enabled.
Related Issue
Motivation and Context
This PR fixes the following warning displayed when the admin is about to reset user's password over the Users management page with masterkey encryption in place:
The warning itself does not prevent resetting user's password but it is scary and makes no sense when masterkey encryption is in use.
How Has This Been Tested?
Manually by enabling masterkey encryption and as admin hovering over the password field for one random user: the warning is not displayed anymore.
Types of changes
Checklist: