diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-09-22 17:04:55 +0400 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-09-23 12:56:01 +0400 |
commit | 5de19f38c4120dbf63ffd135721443633ed7dfa1 (patch) | |
tree | 7e50b6c16e74cae998b11274198a5f0eccb15806 /apps | |
parent | e001dfb3be39ce4121060e883f81b5c41f6c23a6 (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.php | 15 |
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
|