summaryrefslogtreecommitdiffstats
path: root/settings/ajax
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2014-05-13 09:25:16 -0400
committerBjörn Schießle <schiessle@owncloud.com>2014-05-13 09:25:16 -0400
commitb8de1e5d716c416beae328506e368cd0554509e1 (patch)
tree8b13942c27547f4c4266699efc445b0bfe96296d /settings/ajax
parente934129bf6125c50ccede651b544d7ab07d5378a (diff)
parenta9ac11718e62017c70682f99eb35b43b1ef9c498 (diff)
downloadnextcloud-server-b8de1e5d716c416beae328506e368cd0554509e1.tar.gz
nextcloud-server-b8de1e5d716c416beae328506e368cd0554509e1.zip
Merge pull request #8398 from owncloud/enc_backup_keys
backup the encryption key after the encryption was disabled
Diffstat (limited to 'settings/ajax')
-rw-r--r--settings/ajax/deletekeys.php17
-rw-r--r--settings/ajax/restorekeys.php24
2 files changed, 41 insertions, 0 deletions
diff --git a/settings/ajax/deletekeys.php b/settings/ajax/deletekeys.php
new file mode 100644
index 00000000000..1f84452e117
--- /dev/null
+++ b/settings/ajax/deletekeys.php
@@ -0,0 +1,17 @@
+<?php
+
+OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
+
+$l = \OC_L10N::get('settings');
+$user = \OC_User::getUser();
+$view = new \OC\Files\View('/' . $user . '/files_encryption');
+
+$keyfilesDeleted = $view->deleteAll('keyfiles.backup');
+$sharekeysDeleted = $view->deleteAll('share-keys.backup');
+
+if ($keyfilesDeleted && $sharekeysDeleted) {
+ \OCP\JSON::success(array('data' => array('message' => $l->t('Encryption keys deleted permanently'))));
+} else {
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t permanently delete your encryption keys, please check your owncloud.log or ask your administrator'))));
+}
diff --git a/settings/ajax/restorekeys.php b/settings/ajax/restorekeys.php
new file mode 100644
index 00000000000..68e19c90457
--- /dev/null
+++ b/settings/ajax/restorekeys.php
@@ -0,0 +1,24 @@
+<?php
+
+OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
+
+$l = \OC_L10N::get('settings');
+$user = \OC_User::getUser();
+$view = new \OC\Files\View('/' . $user . '/files_encryption');
+
+$keyfilesRestored = $view->rename('keyfiles.backup', 'keyfiles');
+$sharekeysRestored = $view->rename('share-keys.backup' , 'share-keys');
+
+if ($keyfilesRestored && $sharekeysRestored) {
+ \OCP\JSON::success(array('data' => array('message' => $l->t('Backups restored successfully'))));
+} else {
+ // if one of the move operation was succesful we remove the files back to have a consistent state
+ if($keyfilesRestored) {
+ $view->rename('keyfiles', 'keyfiles.backup');
+ }
+ if($sharekeysRestored) {
+ $view->rename('share-keys' , 'share-keys.backup');
+ }
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t restore your encryption keys, please check your owncloud.log or ask your administrator'))));
+}