From 5a261b5b8ffd01c34ce009a431a5587c548fa9a7 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 9 Aug 2012 12:19:51 +0200 Subject: ask user for passwords when switching from client to server side encryption --- apps/files_encryption/ajax/mode.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'apps/files_encryption/ajax') 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 -- cgit v1.2.3