From 195a48b2b85ee324b98cda88a8e17546b33b895d Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 17 Apr 2015 10:52:40 +0200 Subject: fix change password if no user is logged in, occ call --- apps/encryption/hooks/userhooks.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'apps/encryption/hooks') diff --git a/apps/encryption/hooks/userhooks.php b/apps/encryption/hooks/userhooks.php index e61d4f9c119..b09b8e7049a 100644 --- a/apps/encryption/hooks/userhooks.php +++ b/apps/encryption/hooks/userhooks.php @@ -196,7 +196,9 @@ class UserHooks implements IHook { public function preSetPassphrase($params) { if (App::isEnabled('encryption')) { - if (!$this->user->getUser()->canChangePassword()) { + $user = $this->user->getUser(); + + if ($user && !$user->canChangePassword()) { $this->setPassphrase($params); } } @@ -212,8 +214,10 @@ class UserHooks implements IHook { // Get existing decrypted private key $privateKey = $this->session->getPrivateKey(); + $user = $this->user->getUser(); - if ($params['uid'] === $this->user->getUser()->getUID() && $privateKey) { + // current logged in user changes his own password + if ($user && $params['uid'] === $user->getUID() && $privateKey) { // Encrypt private key with new user pwd as passphrase $encryptedPrivateKey = $this->crypt->symmetricEncryptFileContent($privateKey, @@ -230,7 +234,7 @@ class UserHooks implements IHook { // NOTE: Session does not need to be updated as the // private key has not changed, only the passphrase // used to decrypt it has changed - } else { // admin changed the password for a different user, create new keys and reencrypt file keys + } else { // admin changed the password for a different user, create new keys and re-encrypt file keys $user = $params['uid']; $recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null; -- cgit v1.2.3