--
cgit v1.2.3
From 794d3ef949b487011805d50e851e5a07ad7776d4 Mon Sep 17 00:00:00 2001
From: Bjoern Schiessle
Date: Tue, 7 Oct 2014 12:30:50 +0200
Subject: improved visual feedback if recovery key password gets changed
---
.../ajax/changeRecoveryPassword.php | 26 ++++++++++++++++++++++
apps/files_encryption/js/settings-admin.js | 11 ++++-----
apps/files_encryption/templates/settings-admin.php | 4 ++--
3 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/apps/files_encryption/ajax/changeRecoveryPassword.php b/apps/files_encryption/ajax/changeRecoveryPassword.php
index 71fbe333fe0..bf647f2c8fa 100644
--- a/apps/files_encryption/ajax/changeRecoveryPassword.php
+++ b/apps/files_encryption/ajax/changeRecoveryPassword.php
@@ -21,6 +21,32 @@ $return = false;
$oldPassword = $_POST['oldPassword'];
$newPassword = $_POST['newPassword'];
+$confirmPassword = $_POST['confirmPassword'];
+
+//check if both passwords are the same
+if (empty($_POST['oldPassword'])) {
+ $errorMessage = $l->t('Please provide the old recovery password');
+ \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
+ exit();
+}
+
+if (empty($_POST['newPassword'])) {
+ $errorMessage = $l->t('Please provide a new recovery password');
+ \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
+ exit();
+}
+
+if (empty($_POST['confirmPassword'])) {
+ $errorMessage = $l->t('Please repeat the new recovery password');
+ \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
+ exit();
+}
+
+if ($_POST['newPassword'] !== $_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();
+}
$view = new \OC\Files\View('/');
$util = new \OCA\Encryption\Util(new \OC\Files\View('/'), \OCP\User::getUser());
diff --git a/apps/files_encryption/js/settings-admin.js b/apps/files_encryption/js/settings-admin.js
index 38a5cd1b556..2242c1f7124 100644
--- a/apps/files_encryption/js/settings-admin.js
+++ b/apps/files_encryption/js/settings-admin.js
@@ -41,17 +41,14 @@ $(document).ready(function(){
$('button:button[name="submitChangeRecoveryKey"]').click(function() {
var oldRecoveryPassword = $('#oldEncryptionRecoveryPassword').val();
var newRecoveryPassword = $('#newEncryptionRecoveryPassword').val();
- OC.msg.startSaving('#encryption .msg');
+ var confirmNewPassword = $('#repeatedNewEncryptionRecoveryPassword').val();
+ OC.msg.startSaving('#encryptionChangeRecoveryKey .msg');
$.post(
OC.filePath( 'files_encryption', 'ajax', 'changeRecoveryPassword.php' )
- , { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword }
+ , { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword, confirmPassword: confirmNewPassword }
, function( data ) {
- if (data.status == "error") {
- OC.msg.finishedSaving('#encryption .msg', data);
- } else {
- OC.msg.finishedSaving('#encryption .msg', data);
+ OC.msg.finishedSaving('#encryptionChangeRecoveryKey .msg', data);
}
- }
);
});
diff --git a/apps/files_encryption/templates/settings-admin.php b/apps/files_encryption/templates/settings-admin.php
index e97f64b6482..d003f245bb3 100644
--- a/apps/files_encryption/templates/settings-admin.php
+++ b/apps/files_encryption/templates/settings-admin.php
@@ -34,8 +34,9 @@
-
>
+
>
t("Change recovery key password:")); ?>
+
t("Change Password")); ?>
-
--
cgit v1.2.3
From b060123155d82d59c981b89600a3a1b2c9f37bc9 Mon Sep 17 00:00:00 2001
From: Bjoern Schiessle
Date: Tue, 7 Oct 2014 12:52:01 +0200
Subject: improved visual feedback if user enabled recovery key
---
apps/files_encryption/ajax/userrecovery.php | 8 +++++++-
apps/files_encryption/js/settings-personal.js | 21 ++++++---------------
.../templates/settings-personal.php | 5 ++---
3 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/apps/files_encryption/ajax/userrecovery.php b/apps/files_encryption/ajax/userrecovery.php
index 0f3b973d69a..a5b89fa7233 100644
--- a/apps/files_encryption/ajax/userrecovery.php
+++ b/apps/files_encryption/ajax/userrecovery.php
@@ -13,6 +13,8 @@ use OCA\Encryption;
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
+$l = \OC::$server->getL10N('files_encryption');
+
if (
isset($_POST['userEnableRecovery'])
&& (0 == $_POST['userEnableRecovery'] || '1' === $_POST['userEnableRecovery'])
@@ -38,4 +40,8 @@ if (
}
// Return success or failure
-($return) ? \OCP\JSON::success() : \OCP\JSON::error();
+if ($return) {
+ \OCP\JSON::success(array('data' => array('message' => $l->t('File recovery settings updated'))));
+} else {
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Could not update file recovery'))));
+}
diff --git a/apps/files_encryption/js/settings-personal.js b/apps/files_encryption/js/settings-personal.js
index f857c2c9f05..b798ba7e4e1 100644
--- a/apps/files_encryption/js/settings-personal.js
+++ b/apps/files_encryption/js/settings-personal.js
@@ -26,36 +26,27 @@ $(document).ready(function(){
// Trigger ajax on recoveryAdmin status change
$( 'input:radio[name="userEnableRecovery"]' ).change(
function() {
-
- // Hide feedback messages in case they're already visible
- $('#recoveryEnabledSuccess').hide();
- $('#recoveryEnabledError').hide();
-
var recoveryStatus = $( this ).val();
-
+ OC.msg.startAction('#userEnableRecovery .msg', 'Updating recovery keys. This can take some time...');
$.post(
OC.filePath( 'files_encryption', 'ajax', 'userrecovery.php' )
, { userEnableRecovery: recoveryStatus }
, function( data ) {
- if ( data.status == "success" ) {
- $('#recoveryEnabledSuccess').show();
- } else {
- $('#recoveryEnabledError').show();
- }
+ OC.msg.finishedAction('#userEnableRecovery .msg', data);
}
);
// Ensure page is not reloaded on form submit
return false;
}
);
-
+
$("#encryptAll").click(
function(){
-
+
// Hide feedback messages in case they're already visible
$('#encryptAllSuccess').hide();
$('#encryptAllError').hide();
-
+
var userPassword = $( '#userPassword' ).val();
var encryptAll = $( '#encryptAll' ).val();
@@ -73,7 +64,7 @@ $(document).ready(function(){
// Ensure page is not reloaded on form submit
return false;
}
-
+
);
// update private key password
diff --git a/apps/files_encryption/templates/settings-personal.php b/apps/files_encryption/templates/settings-personal.php
index a1221240422..ce8cf6aec28 100644
--- a/apps/files_encryption/templates/settings-personal.php
+++ b/apps/files_encryption/templates/settings-personal.php
@@ -39,8 +39,9 @@
-
+
+
t( "Enabling this option will allow you to reobtain access to your encrypted files in case of password loss" ) ); ?>
@@ -60,8 +61,6 @@
value='0'
/>
-