diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php index 81fb8ded4f86..86f00c1573a9 100644 --- a/settings/Controller/UsersController.php +++ b/settings/Controller/UsersController.php @@ -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 */ @@ -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); @@ -176,23 +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; - } - } else { - // masterkey encryption is active + 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; } diff --git a/tests/Settings/Controller/UsersControllerTest.php b/tests/Settings/Controller/UsersControllerTest.php index 25e1501e0bf6..85cda201c562 100644 --- a/tests/Settings/Controller/UsersControllerTest.php +++ b/tests/Settings/Controller/UsersControllerTest.php @@ -1715,7 +1715,7 @@ public function testRestoreNotPossibleWithoutAdminRestore() { ) ->will($this->returnValue(true)); - $expectedResult['isRestoreDisabled'] = true; + $expectedResult['isRestoreDisabled'] = false; $subadmin = $this->getMockBuilder('\OC\SubAdmin') ->disableOriginalConstructor()