Merge pull request #15978 from owncloud/feature/fix-encryption-tooltips
[enc2]fixing recovery tooltip
This commit is contained in:
commit
257ee205bb
|
@ -113,30 +113,27 @@ class Controller {
|
||||||
$recoveryEnabledForUser = false;
|
$recoveryEnabledForUser = false;
|
||||||
if ($recoveryAdminEnabled) {
|
if ($recoveryAdminEnabled) {
|
||||||
$validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword);
|
$validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword);
|
||||||
$recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser();
|
$recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username);
|
||||||
}
|
}
|
||||||
|
$l = new \OC_L10n('settings');
|
||||||
|
|
||||||
if ($recoveryEnabledForUser && $recoveryPassword === '') {
|
if ($recoveryEnabledForUser && $recoveryPassword === '') {
|
||||||
$l = new \OC_L10n('settings');
|
|
||||||
\OC_JSON::error(array('data' => array(
|
\OC_JSON::error(array('data' => array(
|
||||||
'message' => $l->t('Please provide an admin recovery password, otherwise all user data will be lost')
|
'message' => $l->t('Please provide an admin recovery password, otherwise all user data will be lost')
|
||||||
)));
|
)));
|
||||||
} elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) {
|
} elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) {
|
||||||
$l = new \OC_L10n('settings');
|
|
||||||
\OC_JSON::error(array('data' => array(
|
\OC_JSON::error(array('data' => array(
|
||||||
'message' => $l->t('Wrong admin recovery password. Please check the password and try again.')
|
'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
|
} 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);
|
$result = \OC_User::setPassword($username, $password, $recoveryPassword);
|
||||||
if (!$result && $recoveryEnabledForUser) {
|
if (!$result && $recoveryEnabledForUser) {
|
||||||
$l = new \OC_L10n('settings');
|
|
||||||
\OC_JSON::error(array(
|
\OC_JSON::error(array(
|
||||||
"data" => array(
|
"data" => array(
|
||||||
"message" => $l->t("Backend doesn't support password change, but the user's encryption key was successfully updated.")
|
"message" => $l->t("Backend doesn't support password change, but the user's encryption key was successfully updated.")
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
} elseif (!$result && !$recoveryEnabledForUser) {
|
} elseif (!$result && !$recoveryEnabledForUser) {
|
||||||
$l = new \OC_L10n('settings');
|
|
||||||
\OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change password" ) )));
|
\OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change password" ) )));
|
||||||
} else {
|
} else {
|
||||||
\OC_JSON::success(array("data" => array( "username" => $username )));
|
\OC_JSON::success(array("data" => array( "username" => $username )));
|
||||||
|
@ -147,7 +144,6 @@ class Controller {
|
||||||
if (!is_null($password) && \OC_User::setPassword($username, $password)) {
|
if (!is_null($password) && \OC_User::setPassword($username, $password)) {
|
||||||
\OC_JSON::success(array('data' => array('username' => $username)));
|
\OC_JSON::success(array('data' => array('username' => $username)));
|
||||||
} else {
|
} else {
|
||||||
$l = new \OC_L10n('settings');
|
|
||||||
\OC_JSON::error(array('data' => array('message' => $l->t('Unable to change password'))));
|
\OC_JSON::error(array('data' => array('message' => $l->t('Unable to change password'))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,10 +122,10 @@ class UsersController extends Controller {
|
||||||
$this->subAdminFactory = $subAdminFactory;
|
$this->subAdminFactory = $subAdminFactory;
|
||||||
|
|
||||||
// check for encryption state - TODO see formatUserForIndex
|
// check for encryption state - TODO see formatUserForIndex
|
||||||
$this->isEncryptionAppEnabled = $appManager->isEnabledForUser('files_encryption');
|
$this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption');
|
||||||
if($this->isEncryptionAppEnabled) {
|
if($this->isEncryptionAppEnabled) {
|
||||||
// putting this directly in empty is possible in PHP 5.5+
|
// 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);
|
$this->isRestoreEnabled = !empty($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ class UsersController extends Controller {
|
||||||
if ($this->isEncryptionAppEnabled) {
|
if ($this->isEncryptionAppEnabled) {
|
||||||
if ($this->isRestoreEnabled) {
|
if ($this->isRestoreEnabled) {
|
||||||
// check for the users recovery setting
|
// 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+
|
// method call inside empty is possible with PHP 5.5+
|
||||||
$recoveryModeEnabled = !empty($recoveryMode);
|
$recoveryModeEnabled = !empty($recoveryMode);
|
||||||
if ($recoveryModeEnabled) {
|
if ($recoveryModeEnabled) {
|
||||||
|
|
|
@ -1303,14 +1303,14 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('isEnabledForUser')
|
->method('isEnabledForUser')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('files_encryption')
|
$this->equalTo('encryption')
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
$this->container['Config']
|
$this->container['Config']
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('files_encryption'),
|
$this->equalTo('encryption'),
|
||||||
$this->equalTo('recoveryAdminEnabled'),
|
$this->equalTo('recoveryAdminEnabled'),
|
||||||
$this->anything()
|
$this->anything()
|
||||||
)
|
)
|
||||||
|
@ -1321,8 +1321,8 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->method('getUserValue')
|
->method('getUserValue')
|
||||||
->with(
|
->with(
|
||||||
$this->anything(),
|
$this->anything(),
|
||||||
$this->equalTo('files_encryption'),
|
$this->equalTo('encryption'),
|
||||||
$this->equalTo('recovery_enabled'),
|
$this->equalTo('recoveryEnabled'),
|
||||||
$this->anything()
|
$this->anything()
|
||||||
)
|
)
|
||||||
->will($this->returnValue('1'));
|
->will($this->returnValue('1'));
|
||||||
|
@ -1339,7 +1339,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$this->container['OCP\\App\\IAppManager']
|
$this->container['OCP\\App\\IAppManager']
|
||||||
->method('isEnabledForUser')
|
->method('isEnabledForUser')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('files_encryption')
|
$this->equalTo('encryption')
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
@ -1358,14 +1358,14 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('isEnabledForUser')
|
->method('isEnabledForUser')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('files_encryption')
|
$this->equalTo('encryption')
|
||||||
)
|
)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
$this->container['Config']
|
$this->container['Config']
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with(
|
->with(
|
||||||
$this->equalTo('files_encryption'),
|
$this->equalTo('encryption'),
|
||||||
$this->equalTo('recoveryAdminEnabled'),
|
$this->equalTo('recoveryAdminEnabled'),
|
||||||
$this->anything()
|
$this->anything()
|
||||||
)
|
)
|
||||||
|
@ -1376,8 +1376,8 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->method('getUserValue')
|
->method('getUserValue')
|
||||||
->with(
|
->with(
|
||||||
$this->anything(),
|
$this->anything(),
|
||||||
$this->equalTo('files_encryption'),
|
$this->equalTo('encryption'),
|
||||||
$this->equalTo('recovery_enabled'),
|
$this->equalTo('recoveryEnabled'),
|
||||||
$this->anything()
|
$this->anything()
|
||||||
)
|
)
|
||||||
->will($this->returnValue('0'));
|
->will($this->returnValue('0'));
|
||||||
|
|
Loading…
Reference in New Issue