From 3ef2e668ac9274d72ea4afb73b708d7b2c88f0d7 Mon Sep 17 00:00:00 2001 From: Clark Tomlinson Date: Thu, 30 Apr 2015 10:44:44 -0400 Subject: fixing recovery tooltip --- settings/changepassword/controller.php | 6 +----- settings/controller/userscontroller.php | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/settings/changepassword/controller.php b/settings/changepassword/controller.php index 4a68636d3f8..e6f928930e9 100644 --- a/settings/changepassword/controller.php +++ b/settings/changepassword/controller.php @@ -115,28 +115,25 @@ class Controller { $validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword); $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser(); } + $l = new \OC_L10n('settings'); if ($recoveryEnabledForUser && $recoveryPassword === '') { - $l = new \OC_L10n('settings'); \OC_JSON::error(array('data' => array( 'message' => $l->t('Please provide an admin recovery password, otherwise all user data will be lost') ))); } elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) { - $l = new \OC_L10n('settings'); \OC_JSON::error(array('data' => array( 'message' => $l->t('Wrong admin recovery password. Please check the password and try again.') ))); } else { // now we know that everything is fine regarding the recovery password, let's try to change the password $result = \OC_User::setPassword($username, $password, $recoveryPassword); if (!$result && $recoveryEnabledForUser) { - $l = new \OC_L10n('settings'); \OC_JSON::error(array( "data" => array( "message" => $l->t("Backend doesn't support password change, but the user's encryption key was successfully updated.") ) )); } elseif (!$result && !$recoveryEnabledForUser) { - $l = new \OC_L10n('settings'); \OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change password" ) ))); } else { \OC_JSON::success(array("data" => array( "username" => $username ))); @@ -147,7 +144,6 @@ class Controller { if (!is_null($password) && \OC_User::setPassword($username, $password)) { \OC_JSON::success(array('data' => array('username' => $username))); } else { - $l = new \OC_L10n('settings'); \OC_JSON::error(array('data' => array('message' => $l->t('Unable to change password')))); } } diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php index 46782a0cace..588142257ef 100644 --- a/settings/controller/userscontroller.php +++ b/settings/controller/userscontroller.php @@ -122,10 +122,10 @@ class UsersController extends Controller { $this->subAdminFactory = $subAdminFactory; // check for encryption state - TODO see formatUserForIndex - $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('files_encryption'); + $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption'); if($this->isEncryptionAppEnabled) { // putting this directly in empty is possible in PHP 5.5+ - $result = $config->getAppValue('files_encryption', 'recoveryAdminEnabled', 0); + $result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0); $this->isRestoreEnabled = !empty($result); } } @@ -148,7 +148,7 @@ class UsersController extends Controller { if ($this->isEncryptionAppEnabled) { if ($this->isRestoreEnabled) { // check for the users recovery setting - $recoveryMode = $this->config->getUserValue($user->getUID(), 'files_encryption', 'recovery_enabled', '0'); + $recoveryMode = $this->config->getUserValue($user->getUID(), 'encryption', 'recoveryEnabled', '0'); // method call inside empty is possible with PHP 5.5+ $recoveryModeEnabled = !empty($recoveryMode); if ($recoveryModeEnabled) { -- cgit v1.2.3 From 10d7eb56aff51b17bd79a420edb1c541a588eedd Mon Sep 17 00:00:00 2001 From: Clark Tomlinson Date: Tue, 5 May 2015 09:42:53 -0400 Subject: adding username as param for isrecoveryenabled --- settings/changepassword/controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/changepassword/controller.php b/settings/changepassword/controller.php index e6f928930e9..94323fc2fcc 100644 --- a/settings/changepassword/controller.php +++ b/settings/changepassword/controller.php @@ -113,7 +113,7 @@ class Controller { $recoveryEnabledForUser = false; if ($recoveryAdminEnabled) { $validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword); - $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser(); + $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username); } $l = new \OC_L10n('settings'); -- cgit v1.2.3 From 9727386d8b343b9ab2db7604cee012e359c2c9ad Mon Sep 17 00:00:00 2001 From: Clark Tomlinson Date: Mon, 11 May 2015 09:38:23 -0400 Subject: fixing test --- tests/settings/controller/userscontrollertest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php index 25c935bef58..0e34de90914 100644 --- a/tests/settings/controller/userscontrollertest.php +++ b/tests/settings/controller/userscontrollertest.php @@ -1303,14 +1303,14 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->once()) ->method('isEnabledForUser') ->with( - $this->equalTo('files_encryption') + $this->equalTo('encryption') ) ->will($this->returnValue(true)); $this->container['Config'] ->expects($this->once()) ->method('getAppValue') ->with( - $this->equalTo('files_encryption'), + $this->equalTo('encryption'), $this->equalTo('recoveryAdminEnabled'), $this->anything() ) @@ -1321,8 +1321,8 @@ class UsersControllerTest extends \Test\TestCase { ->method('getUserValue') ->with( $this->anything(), - $this->equalTo('files_encryption'), - $this->equalTo('recovery_enabled'), + $this->equalTo('encryption'), + $this->equalTo('recoveryEnabled'), $this->anything() ) ->will($this->returnValue('1')); @@ -1339,7 +1339,7 @@ class UsersControllerTest extends \Test\TestCase { $this->container['OCP\\App\\IAppManager'] ->method('isEnabledForUser') ->with( - $this->equalTo('files_encryption') + $this->equalTo('encryption') ) ->will($this->returnValue(true)); @@ -1358,14 +1358,14 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->once()) ->method('isEnabledForUser') ->with( - $this->equalTo('files_encryption') + $this->equalTo('encryption') ) ->will($this->returnValue(true)); $this->container['Config'] ->expects($this->once()) ->method('getAppValue') ->with( - $this->equalTo('files_encryption'), + $this->equalTo('encryption'), $this->equalTo('recoveryAdminEnabled'), $this->anything() ) @@ -1376,8 +1376,8 @@ class UsersControllerTest extends \Test\TestCase { ->method('getUserValue') ->with( $this->anything(), - $this->equalTo('files_encryption'), - $this->equalTo('recovery_enabled'), + $this->equalTo('encryption'), + $this->equalTo('recoveryEnabled'), $this->anything() ) ->will($this->returnValue('0')); -- cgit v1.2.3