]> source.dussan.org Git - nextcloud-server.git/commitdiff
merge master into sessionclass
authorRobin Appelman <icewind@owncloud.com>
Tue, 28 May 2013 12:55:42 +0000 (14:55 +0200)
committerRobin Appelman <icewind@owncloud.com>
Tue, 28 May 2013 12:55:42 +0000 (14:55 +0200)
1  2 
apps/files_encryption/lib/session.php

index 30cb7b0e1b310b0088b01021ae7e609b14a10a3e,1551275c63f5d498ff0db2b06b16f17691d04e30..34913039b0ccbcf1748daa6c2499d8c52a8fbbe2
@@@ -119,14 -118,42 +118,42 @@@ class Sessio
         */
        public function getPrivateKey() {
  
-               if ( !is_null( \OC::$session->get('privateKey') ) ) {
+               // return the public share private key if this is a public access
+               if (\OCA\Encryption\Helper::isPublicAccess()) {
+                       return $this->getPublicSharePrivateKey();
+               } else {
 -                      if (isset($_SESSION['privateKey']) && !empty($_SESSION['privateKey'])) {
 -                              return $_SESSION['privateKey'];
++                      if (!is_null( \OC::$session->get('privateKey') )) {
++                              return \OC::$session->get('privateKey');
+                       } else {
+                               return false;
+                       }
+               }
+       }
  
-                       return \OC::$session->get('privateKey');
+       /**
+        * @brief Sets public user private key to session
+        * @param string $privateKey
+        * @return bool
+        */
+       public function setPublicSharePrivateKey($privateKey) {
  
-               } else {
 -              $_SESSION['publicSharePrivateKey'] = $privateKey;
++                      \OC::$session->set('publicSharePrivateKey', $privateKey);
  
-                       return false;
+               return true;
+       }
  
+       /**
+        * @brief Gets public share private key from session
+        * @returns string $privateKey
+        *
+        */
+       public function getPublicSharePrivateKey() {
+               if (isset($_SESSION['publicSharePrivateKey']) && !empty($_SESSION['publicSharePrivateKey'])) {
+                       return $_SESSION['publicSharePrivateKey'];
+               } else {
+                       return false;
                }
  
        }