summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/ajax/adminrecovery.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-10-07 12:06:46 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-10-07 12:32:09 +0200
commit5fa1cbc4e5aa0c0127713859291a0b14a8b8e348 (patch)
tree1fca9cf2185fb2b20be2b07b2d77d6606fc2c5bf /apps/files_encryption/ajax/adminrecovery.php
parent94a9ff1cd8b18577e16bde90146b0be84223d725 (diff)
downloadnextcloud-server-5fa1cbc4e5aa0c0127713859291a0b14a8b8e348.tar.gz
nextcloud-server-5fa1cbc4e5aa0c0127713859291a0b14a8b8e348.zip
improved visual feedback if recovery key gets enabled/disabled
Diffstat (limited to 'apps/files_encryption/ajax/adminrecovery.php')
-rw-r--r--apps/files_encryption/ajax/adminrecovery.php48
1 files changed, 31 insertions, 17 deletions
diff --git a/apps/files_encryption/ajax/adminrecovery.php b/apps/files_encryption/ajax/adminrecovery.php
index 070ca6f667e..684fd51ae13 100644
--- a/apps/files_encryption/ajax/adminrecovery.php
+++ b/apps/files_encryption/ajax/adminrecovery.php
@@ -16,8 +16,28 @@ use OCA\Encryption;
$l = \OC::$server->getL10N('files_encryption');
$return = false;
-// Enable recoveryAdmin
+$errorMessage = $l->t("Unknown error");
+
+//check if both passwords are the same
+if (empty($_POST['recoveryPassword'])) {
+ $errorMessage = $l->t('Missing recovery key password');
+ \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
+ exit();
+}
+if (empty($_POST['confirmPassword'])) {
+ $errorMessage = $l->t('Please repeat the recovery key password');
+ \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
+ exit();
+}
+
+if ($_POST['recoveryPassword'] !== $_POST['confirmPassword']) {
+ $errorMessage = $l->t('Repeated recovery key password does not match the provided recovery key password');
+ \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
+ exit();
+}
+
+// Enable recoveryAdmin
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') {
@@ -26,14 +46,9 @@ if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1
// Return success or failure
if ($return) {
- \OCP\JSON::success(array('data' => array('message' => $l->t('Recovery key successfully enabled'))));
+ $successMessage = $l->t('Recovery key successfully enabled');
} else {
- \OCP\JSON::error(array(
- 'data' => array(
- 'message' => $l->t(
- 'Could not enable recovery key. Please check your recovery key password!')
- )
- ));
+ $errorMessage = $l->t('Could not disable recovery key. Please check your recovery key password!');
}
// Disable recoveryAdmin
@@ -43,17 +58,16 @@ if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1
) {
$return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']);
- // Return success or failure
if ($return) {
- \OCP\JSON::success(array('data' => array('message' => $l->t('Recovery key successfully disabled'))));
+ $successMessage = $l->t('Recovery key successfully disabled');
} else {
- \OCP\JSON::error(array(
- 'data' => array(
- 'message' => $l->t(
- 'Could not disable recovery key. Please check your recovery key password!')
- )
- ));
+ $errorMessage = $l->t('Could not disable recovery key. Please check your recovery key password!');
}
}
-
+// Return success or failure
+if ($return) {
+ \OCP\JSON::success(array('data' => array('message' => $successMessage)));
+} else {
+ \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
+}