diff options
author | Joas Schilling <coding@schilljs.com> | 2019-08-26 15:22:00 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-09-15 12:04:28 +0200 |
commit | 16d47b5928a4351aec444ad9a7f90a6e8d2a4676 (patch) | |
tree | f28c9118cdcf242e4d4a9f84dc7ce184e02be774 /apps/encryption/lib/Hooks | |
parent | 0a874c51af8dd6652c694f0545489af23d53771a (diff) | |
download | nextcloud-server-16d47b5928a4351aec444ad9a7f90a6e8d2a4676.tar.gz nextcloud-server-16d47b5928a4351aec444ad9a7f90a6e8d2a4676.zip |
Fix wrongly mixed mock objects in encryption tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/encryption/lib/Hooks')
-rw-r--r-- | apps/encryption/lib/Hooks/UserHooks.php | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/apps/encryption/lib/Hooks/UserHooks.php b/apps/encryption/lib/Hooks/UserHooks.php index 48815892900..bf3f3f42b47 100644 --- a/apps/encryption/lib/Hooks/UserHooks.php +++ b/apps/encryption/lib/Hooks/UserHooks.php @@ -68,7 +68,7 @@ class UserHooks implements IHook { /** * @var IUserSession */ - private $user; + private $userSession; /** * @var Util */ @@ -93,7 +93,7 @@ class UserHooks implements IHook { * @param IUserManager $userManager * @param ILogger $logger * @param Setup $userSetup - * @param IUserSession $user + * @param IUserSession $userSession * @param Util $util * @param Session $session * @param Crypt $crypt @@ -103,7 +103,7 @@ class UserHooks implements IHook { IUserManager $userManager, ILogger $logger, Setup $userSetup, - IUserSession $user, + IUserSession $userSession, Util $util, Session $session, Crypt $crypt, @@ -113,7 +113,7 @@ class UserHooks implements IHook { $this->userManager = $userManager; $this->logger = $logger; $this->userSetup = $userSetup; - $this->user = $user; + $this->userSession = $userSession; $this->util = $util; $this->session = $session; $this->recovery = $recovery; @@ -253,7 +253,7 @@ class UserHooks implements IHook { } // Get existing decrypted private key - $user = $this->user->getUser(); + $user = $this->userSession->getUser(); // current logged in user changes his own password if ($user && $params['uid'] === $user->getUID()) { @@ -265,7 +265,7 @@ class UserHooks implements IHook { // Save private key if ($encryptedPrivateKey) { - $this->keyManager->setPrivateKey($this->user->getUser()->getUID(), + $this->keyManager->setPrivateKey($user->getUID(), $this->crypt->generateHeader() . $encryptedPrivateKey); } else { $this->logger->error('Encryption could not update users encryption password'); @@ -275,8 +275,8 @@ class UserHooks implements IHook { // 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 re-encrypt file keys - $user = $params['uid']; - $this->initMountPoints($user); + $userId = $params['uid']; + $this->initMountPoints($userId); $recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null; $recoveryKeyId = $this->keyManager->getRecoveryKeyId(); @@ -296,9 +296,9 @@ class UserHooks implements IHook { // ...encryption was activated for the first time (no keys exists) // ...the user doesn't have any files if ( - ($this->recovery->isRecoveryEnabledForUser($user) && $recoveryPassword) - || !$this->keyManager->userHasKeys($user) - || !$this->util->userHasFiles($user) + ($this->recovery->isRecoveryEnabledForUser($userId) && $recoveryPassword) + || !$this->keyManager->userHasKeys($userId) + || !$this->util->userHasFiles($userId) ) { // backup old keys @@ -309,16 +309,16 @@ class UserHooks implements IHook { $keyPair = $this->crypt->createKeyPair(); // Save public key - $this->keyManager->setPublicKey($user, $keyPair['publicKey']); + $this->keyManager->setPublicKey($userId, $keyPair['publicKey']); // Encrypt private key with new password - $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $user); + $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId); if ($encryptedKey) { - $this->keyManager->setPrivateKey($user, $this->crypt->generateHeader() . $encryptedKey); + $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey); if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files - $this->recovery->recoverUsersFiles($recoveryPassword, $user); + $this->recovery->recoverUsersFiles($recoveryPassword, $userId); } } else { $this->logger->error('Encryption Could not update users encryption password'); |