@@ -23,7 +23,6 @@ class KeyManager {
2323 private string $ recoveryKeyId ;
2424 private string $ publicShareKeyId ;
2525 private string $ masterKeyId ;
26- private ?string $ keyUid ;
2726 private string $ publicKeyId = 'publicKey ' ;
2827 private string $ privateKeyId = 'privateKey ' ;
2928 private string $ shareKeyId = 'shareKey ' ;
@@ -33,7 +32,7 @@ public function __construct(
3332 private IStorage $ keyStorage ,
3433 private Crypt $ crypt ,
3534 private IConfig $ config ,
36- IUserSession $ userSession ,
35+ private IUserSession $ userSession ,
3736 private Session $ session ,
3837 private LoggerInterface $ logger ,
3938 private Util $ util ,
@@ -61,8 +60,6 @@ public function __construct(
6160 $ this ->masterKeyId = 'master_ ' . substr (md5 ((string )time ()), 0 , 8 );
6261 $ this ->config ->setAppValue ('encryption ' , 'masterKeyId ' , $ this ->masterKeyId );
6362 }
64-
65- $ this ->keyUid = $ userSession ->isLoggedIn () ? $ userSession ->getUser ()?->getUID() : null ;
6663 }
6764
6865 /**
@@ -352,7 +349,7 @@ public function getPrivateKey($userId) {
352349 * @param ?bool $useLegacyFileKey null means try both
353350 */
354351 public function getFileKey (string $ path , ?bool $ useLegacyFileKey , bool $ useDecryptAll = false ): string {
355- $ publicAccess = ( $ this ->keyUid === null );
352+ $ publicAccess = ! $ this ->userSession -> isLoggedIn ( );
356353 $ encryptedFileKey = '' ;
357354 if ($ useLegacyFileKey ?? true ) {
358355 $ encryptedFileKey = $ this ->keyStorage ->getFileKey ($ path , $ this ->fileKeyId , Encryption::ID );
@@ -381,7 +378,7 @@ public function getFileKey(string $path, ?bool $useLegacyFileKey, bool $useDecry
381378 $ privateKey = $ this ->keyStorage ->getSystemUserKey ($ this ->publicShareKeyId . '. ' . $ this ->privateKeyId , Encryption::ID );
382379 $ privateKey = $ this ->crypt ->decryptPrivateKey ($ privateKey );
383380 } else {
384- $ uid = $ this ->keyUid ;
381+ $ uid = $ this ->userSession -> getUser ()?->getUID() ;
385382 $ shareKey = $ this ->getShareKey ($ path , $ uid );
386383 $ privateKey = $ this ->session ->getPrivateKey ();
387384 }
0 commit comments