summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-07-29 17:06:05 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-07-29 17:06:05 +0200
commitb6fa0e4eefb332dc1fb9b45df50de4621ed8e6bd (patch)
tree2ca892180568bd5c76facbfd9e6762621485a5dd /settings
parent830f5d24c77b863bd49eda0cbc4ba812add8065d (diff)
downloadnextcloud-server-b6fa0e4eefb332dc1fb9b45df50de4621ed8e6bd.tar.gz
nextcloud-server-b6fa0e4eefb332dc1fb9b45df50de4621ed8e6bd.zip
working decrypt files method
Diffstat (limited to 'settings')
-rw-r--r--settings/ajax/decryptall.php23
-rw-r--r--settings/js/personal.js57
-rw-r--r--settings/personal.php5
-rw-r--r--settings/templates/personal.php10
4 files changed, 76 insertions, 19 deletions
diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php
index 02a9bfe96b1..7adacb9802a 100644
--- a/settings/ajax/decryptall.php
+++ b/settings/ajax/decryptall.php
@@ -1,14 +1,21 @@
<?php
+sleep(10);
+//encryption app needs to be loaded
+OC_App::loadApp('files_encryption');
-$status = OC_App::isEnabled('files_encryption');
-OC_App::enable('files_encryption');
+// init encryption app
+$params = array('uid' => \OCP\User::getUser(),
+ 'password' => $_POST['password']);
-OCA\Encryption\Crypt::decryptAll();
-
-if ($status === false) {
- OC_App::disable('files_encryption');
-}
+$view = new OC_FilesystemView('/');
+$util = new \OCA\Encryption\Util($view, \OCP\User::getUser());
+$result = $util->initEncryption($params);
-\OCP\JSON::success(array('data' => array('message' => 'looks good')));
+if ($result !== false) {
+ $util->decryptAll();
+ \OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
+} else {
+ \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt files, check your password and try again')));
+}
diff --git a/settings/js/personal.js b/settings/js/personal.js
index 97342e7653e..94ef959488f 100644
--- a/settings/js/personal.js
+++ b/settings/js/personal.js
@@ -112,18 +112,59 @@ $(document).ready(function(){
});
$('button:button[name="submitDecryptAll"]').click(function() {
- console.log("click!");
- $.post('ajax/decryptall.php', {}, function(data) {
- /*
+ var privateKeyPassword = $('#decryptAll input:password[id="privateKeyPassword"]').val();
+ OC.Encryption.decryptAll(privateKeyPassword);
+ });
+
+ $('#decryptAll input:password[name="privateKeyPassword"]').keyup(function(event) {
+ var privateKeyPassword = $('#decryptAll input:password[id="privateKeyPassword"]').val();
+ if (privateKeyPassword !== '' ) {
+ $('#decryptAll button:button[name="submitDecryptAll"]').removeAttr("disabled");
+ if(event.which === 13) {
+ OC.Encryption.decryptAll(privateKeyPassword);
+ }
+ } else {
+ $('#decryptAll button:button[name="submitDecryptAll"]').attr("disabled", "true");
+ }
+ });
+
+} );
+
+OC.Encryption = {
+ decryptAll: function(password) {
+ OC.Encryption.msg.startDecrypting('#decryptAll .msg');
+ $.post('ajax/decryptall.php', {password:password}, function(data) {
if (data.status === "error") {
- OC.msg.finishedSaving('#encryption .msg', data);
+ OC.Encryption.msg.finishedDecrypting('#decryptAll .msg', data);
} else {
- OC.msg.finishedSaving('#encryption .msg', data);
- }*/
+ OC.Encryption.msg.finishedDecrypting('#decryptAll .msg', data);
+ }
}
);
- });
-} );
+ }
+}
+
+OC.Encryption.msg={
+ startDecrypting:function(selector){
+ $(selector)
+ .html( t('files_encryption', 'Decrypting files... Please wait, this can take some time.') )
+ .removeClass('success')
+ .removeClass('error')
+ .stop(true, true)
+ .show();
+ },
+ finishedDecrypting:function(selector, data){
+ if( data.status === "success" ){
+ $(selector).html( data.data.message )
+ .addClass('success')
+ .stop(true, true)
+ .delay(3000)
+ .fadeOut(900);
+ }else{
+ $(selector).html( data.data.message ).addClass('error');
+ }
+ }
+};
OC.msg={
startSaving:function(selector){
diff --git a/settings/personal.php b/settings/personal.php
index 79ce8e4576b..f10b0afb096 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -27,8 +27,9 @@ $languageCodes=OC_L10N::findAvailableLanguages();
//check if encryption was enabled in the past
$enableDecryptAll = false;
if (OC_App::isEnabled('files_encryption') === false) {
- $view = new OC\Files\View('/'.OC_User::getUser());
- if ($view->file_exists('files_encryption/keyfiles')) {
+ $view = new OC\Files\View('/'.OCP\User::getUser());
+ $remainingKeys = $view->getDirectoryContent('/files_encryption/keyfiles');
+ if (!empty($remainingKeys)) {
$enableDecryptAll = true;
}
}
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index c0f3600a51e..7e926ea42b0 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -111,17 +111,25 @@ if($_['passwordChangeSupported']) {
};?>
<?php if($_['enableDecryptAll']): ?>
-<form id="encryption">
+<form id="decryptAll">
<fieldset class="personalblock">
<legend>
<?php p( $l->t( 'Encryption' ) ); ?>
</legend>
<?php p($l->t( "The encryption app is no longer enabled, decrypt all your file" )); ?>
<p>
+ <input
+ type="password"
+ name="privateKeyPassword"
+ id="privateKeyPassword" />
+ <label for="privateKeyPassword"><?php p($l->t( "Log-in password" )); ?></label>
+ <br />
<button
type="button"
+ disabled
name="submitDecryptAll"><?php p($l->t( "Decrypt all Files" )); ?>
</button>
+ <span class="msg"></span>
</p>
<br />
</fieldset>