diff options
author | Björn Schießle <bjoern@schiessle.org> | 2013-08-18 09:51:48 -0700 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2013-08-18 09:51:48 -0700 |
commit | 9be836814cb4165ea54a086a0f97526d783bcd37 (patch) | |
tree | ad57d30194571edcf0f51cd83178b8ac2f03c0aa /settings | |
parent | c620c5840ab8ca45531c7639e086bafbd87d7365 (diff) | |
parent | d544a371bfb84f36a3b789d19d44d6694de21c48 (diff) | |
download | nextcloud-server-9be836814cb4165ea54a086a0f97526d783bcd37.tar.gz nextcloud-server-9be836814cb4165ea54a086a0f97526d783bcd37.zip |
Merge pull request #4239 from owncloud/decrypt_files_again
Enable user to decrypt files again after encryption app was disabled
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/decryptall.php | 25 | ||||
-rw-r--r-- | settings/js/personal.js | 54 | ||||
-rw-r--r-- | settings/personal.php | 4 | ||||
-rw-r--r-- | settings/routes.php | 2 | ||||
-rw-r--r-- | settings/templates/personal.php | 26 |
5 files changed, 111 insertions, 0 deletions
diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php new file mode 100644 index 00000000000..e53067931e8 --- /dev/null +++ b/settings/ajax/decryptall.php @@ -0,0 +1,25 @@ +<?php + +//encryption app needs to be loaded +OC_App::loadApp('files_encryption'); + +// init encryption app +$params = array('uid' => \OCP\User::getUser(), + 'password' => $_POST['password']); + +$view = new OC_FilesystemView('/'); +$util = new \OCA\Encryption\Util($view, \OCP\User::getUser()); + +$result = $util->initEncryption($params); + +if ($result !== false) { + $successful = $util->decryptAll(); + if ($successful === true) { + \OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully'))); + } else { + \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator'))); + } +} else { + \OCP\JSON::error(array('data' => array('message' => 'Couldn\'t decrypt your files, check your password and try again'))); +} + diff --git a/settings/js/personal.js b/settings/js/personal.js index 099c1426dc0..94ef959488f 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -110,8 +110,62 @@ $(document).ready(function(){ }); return false; }); + + $('button:button[name="submitDecryptAll"]').click(function() { + 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.Encryption.msg.finishedDecrypting('#decryptAll .msg', data); + } else { + 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){ $(selector) diff --git a/settings/personal.php b/settings/personal.php index 1e2e1cf6723..e69898f6f8f 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -24,6 +24,9 @@ $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', ''); $userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() ); $languageCodes=OC_L10N::findAvailableLanguages(); +//check if encryption was enabled in the past +$enableDecryptAll = OC_Util::encryptedFiles(); + // array of common languages $commonlangcodes = array( 'en', 'es', 'fr', 'de', 'de_DE', 'ja_JP', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'zh_CN', 'ko' @@ -80,6 +83,7 @@ $tmpl->assign('activelanguage', $userLang); $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser())); $tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser())); $tmpl->assign('displayName', OC_User::getDisplayName()); +$tmpl->assign('enableDecryptAll' , $enableDecryptAll); $forms=OC_App::getForms('personal'); $tmpl->assign('forms', array()); diff --git a/settings/routes.php b/settings/routes.php index b20119b5803..73ee70d1d5c 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -46,6 +46,8 @@ $this->create('settings_ajax_lostpassword', '/settings/ajax/lostpassword.php') ->actionInclude('settings/ajax/lostpassword.php'); $this->create('settings_ajax_setlanguage', '/settings/ajax/setlanguage.php') ->actionInclude('settings/ajax/setlanguage.php'); +$this->create('settings_ajax_decryptall', '/settings/ajax/decryptall.php') + ->actionInclude('settings/ajax/decryptall.php'); // apps $this->create('settings_ajax_apps_ocs', '/settings/ajax/apps/ocs.php') ->actionInclude('settings/ajax/apps/ocs.php'); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 7d677bdd455..bad88142da9 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -110,6 +110,32 @@ if($_['passwordChangeSupported']) { print_unescaped($form); };?> +<?php if($_['enableDecryptAll']): ?> +<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> +</form> +<?php endif; ?> + <fieldset class="personalblock"> <legend><strong><?php p($l->t('Version'));?></strong></legend> <strong><?php p($theme->getName()); ?></strong> <?php p(OC_Util::getVersionString()); ?><br/> |