From c6e243928c1dca7995202178aaddc919fe4d40ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 17 Apr 2015 17:51:18 +0200 Subject: [PATCH] move creation of shared key to the login handler - fixes #15705 --- apps/encryption/lib/keymanager.php | 8 +++++--- apps/encryption/lib/users/setup.php | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php index b451b5c25a..0c6edd49c8 100644 --- a/apps/encryption/lib/keymanager.php +++ b/apps/encryption/lib/keymanager.php @@ -130,6 +130,11 @@ class KeyManager { $this->config->setAppValue('encryption', 'publicShareKeyId', $this->publicShareKeyId); } + $this->keyId = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : false; + $this->log = $log; + } + + public function validateShareKey() { $shareKey = $this->getPublicShareKey(); if (empty($shareKey)) { $keyPair = $this->crypt->createKeyPair(); @@ -143,9 +148,6 @@ class KeyManager { $header = $this->crypt->generateHeader(); $this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey); } - - $this->keyId = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : false; - $this->log = $log; } /** diff --git a/apps/encryption/lib/users/setup.php b/apps/encryption/lib/users/setup.php index 2ec49b5c7f..fd8261cc63 100644 --- a/apps/encryption/lib/users/setup.php +++ b/apps/encryption/lib/users/setup.php @@ -79,6 +79,7 @@ class Setup { * @return bool */ public function setupServerSide($uid, $password) { + $this->keyManager->validateShareKey(); // Check if user already has keys if (!$this->keyManager->userHasKeys($uid)) { return $this->keyManager->storeKeyPair($uid, $password,