summaryrefslogtreecommitdiffstats
path: root/apps/encryption/hooks
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-17 10:52:40 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-04-17 13:26:38 +0200
commit195a48b2b85ee324b98cda88a8e17546b33b895d (patch)
tree7becd87b31fee37db33399e778caa749fdfdc6b5 /apps/encryption/hooks
parentf32d97750c33942db53a56d1deceacb2ed3e779b (diff)
downloadnextcloud-server-195a48b2b85ee324b98cda88a8e17546b33b895d.tar.gz
nextcloud-server-195a48b2b85ee324b98cda88a8e17546b33b895d.zip
fix change password if no user is logged in, occ call
Diffstat (limited to 'apps/encryption/hooks')
-rw-r--r--apps/encryption/hooks/userhooks.php10
1 files changed, 7 insertions, 3 deletions
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;