summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/ajax
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2012-08-09 12:19:51 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2012-08-09 12:19:51 +0200
commit5a261b5b8ffd01c34ce009a431a5587c548fa9a7 (patch)
tree4d178eb6b8c63db84953b4219a27a6aca42b242c /apps/files_encryption/ajax
parenta7cbc9e71398d5e08684ffdfd1f07e7d8defbf31 (diff)
downloadnextcloud-server-5a261b5b8ffd01c34ce009a431a5587c548fa9a7.tar.gz
nextcloud-server-5a261b5b8ffd01c34ce009a431a5587c548fa9a7.zip
ask user for passwords when switching from client to server side encryption
Diffstat (limited to 'apps/files_encryption/ajax')
-rw-r--r--apps/files_encryption/ajax/mode.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/apps/files_encryption/ajax/mode.php b/apps/files_encryption/ajax/mode.php
index 0515cdccb0a..c81d4947956 100644
--- a/apps/files_encryption/ajax/mode.php
+++ b/apps/files_encryption/ajax/mode.php
@@ -7,11 +7,22 @@
//TODO: Handle switch between client and server side encryption
+use OCA_Encryption\Keymanager;
+
OCP\JSON::checkAppEnabled('files_encryption');
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$mode = $_POST['mode'];
+$changePasswd = false;
+$passwdChanged = false;
+
+if ( isset($_POST['newpasswd']) && isset($_POST['oldpasswd']) ) {
+ $oldpasswd = $_POST['oldpasswd'];
+ $newpasswd = $_POST['newpasswd'];
+ $changePasswd = true;
+ $passwdChanged = Keymanager::changePasswd($oldpasswd, $newpasswd);
+}
$query = \OC_DB::prepare( "SELECT mode FROM *PREFIX*encryption WHERE uid = ?" );
$result = $query->execute(array(\OCP\User::getUser()));
@@ -21,4 +32,8 @@ if ($result->fetchRow()){
} else {
$query = OC_DB::prepare( 'INSERT INTO *PREFIX*encryption ( mode, uid ) VALUES( ?, ? )' );
}
-$query->execute(array($mode, \OCP\User::getUser())); \ No newline at end of file
+if ( (!$changePasswd || $passwdChanged) && $query->execute(array($mode, \OCP\User::getUser())) ) {
+ OCP\JSON::success();
+} else {
+ OCP\JSON::error();
+} \ No newline at end of file