Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-09-22 17:04:55 +0400
committerBjoern Schiessle <schiessle@owncloud.com>2014-09-23 12:56:01 +0400
commit5de19f38c4120dbf63ffd135721443633ed7dfa1 (patch)
tree7e50b6c16e74cae998b11274198a5f0eccb15806 /apps
parente001dfb3be39ce4121060e883f81b5c41f6c23a6 (diff)
first check if a private key exists, if not it is always a recovery szenario
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/hooks/hooks.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 894ad311616..f843d8a9bf8 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -195,19 +195,22 @@ class Hooks {
if (Crypt::mode() === 'server') {
$view = new \OC_FilesystemView('/');
+ $session = new \OCA\Encryption\Session($view);
- if ($params['uid'] === \OCP\User::getUser()) {
+ // Get existing decrypted private key
+ $privateKey = $session->getPrivateKey();
- $session = new \OCA\Encryption\Session($view);
-
- // Get existing decrypted private key
- $privateKey = $session->getPrivateKey();
+ if ($params['uid'] === \OCP\User::getUser() && $privateKey) {
// Encrypt private key with new user pwd as passphrase
$encryptedPrivateKey = Crypt::symmetricEncryptFileContent($privateKey, $params['password']);
// Save private key
- Keymanager::setPrivateKey($encryptedPrivateKey);
+ if ($encryptedPrivateKey) {
+ Keymanager::setPrivateKey($encryptedPrivateKey);
+ } else {
+ \OCP\Util::writeLog('files_encryption', 'Could not update users encryption password', \OCP\Util::ERROR);
+ }
// NOTE: Session does not need to be updated as the
// private key has not changed, only the passphrase