Skip to content

Commit

Permalink
Merge pull request #36523 from owncloud/password-reset-masterkey-fix
Browse files Browse the repository at this point in the history
Fix warning when resetting user's password with masterkey encryption
  • Loading branch information
micbar authored Dec 20, 2019
2 parents a2be500 + 6e31d51 commit fc33551
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/36523
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: suppress warning when resetting user password with masterkey encryption

When an admin wanted to reset user's password over the Users management page with masterkey encryption in place, a warning was displayed about data recovery not being available. The behavior has now been fixed.

https://github.com/owncloud/core/pull/36523
26 changes: 10 additions & 16 deletions settings/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class UsersController extends Controller {
private $fromMailAddress;
/** @var IURLGenerator */
private $urlGenerator;
/** @var bool contains the state of the encryption app */
private $isEncryptionAppEnabled;
/** @var bool contains the state of the admin recovery setting */
private $isRestoreEnabled = false;
/** @var IAvatarManager */
Expand Down Expand Up @@ -153,8 +151,7 @@ public function __construct($appName,
$this->eventDispatcher = $eventDispatcher;

// check for encryption state - TODO see formatUserForIndex
$this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption');
if ($this->isEncryptionAppEnabled) {
if ($appManager->isEnabledForUser('encryption')) {
// putting this directly in empty is possible in PHP 5.5+
$result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0);
$this->isRestoreEnabled = !empty($result);
Expand All @@ -176,20 +173,17 @@ private function formatUserForIndex(IUser $user, array $userGroups = null) {
// below
$restorePossible = false;

if ($this->isEncryptionAppEnabled) {
if ($this->isRestoreEnabled) {
// check for the users recovery setting
$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;
}
if ($this->isRestoreEnabled) {
// check for the users recovery setting
$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 {
// recovery is possible if encryption is disabled (plain files are
// available)
// masterkey encryption or no encryption in place
$restorePossible = true;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Settings/Controller/UsersControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ public function testRestoreNotPossibleWithoutAdminRestore() {
)
->will($this->returnValue(true));

$expectedResult['isRestoreDisabled'] = true;
$expectedResult['isRestoreDisabled'] = false;

$subadmin = $this->getMockBuilder('\OC\SubAdmin')
->disableOriginalConstructor()
Expand Down

0 comments on commit fc33551

Please sign in to comment.