No need to store credentials for app if it is the same as the base horde credentials
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 8 Oct 2010 23:30:32 +0000 (17:30 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Sat, 9 Oct 2010 07:20:06 +0000 (01:20 -0600)
framework/Core/lib/Horde/Registry.php

index 74ddbdc..67e4072 100644 (file)
@@ -1922,7 +1922,17 @@ class Horde_Registry
         }
 
         $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
-        $_SESSION['horde_auth']['app'][$app] = $secret->write($secret->getKey('auth'), serialize($credentials));
+        $entry = $secret->write($secret->getKey('auth'), serialize($credentials));
+
+        if (isset($_SESSION['horde_auth']['credentials'])) {
+            $base_app = $_SESSION['horde_auth']['credentials'];
+            if (isset($_SESSION['horde_auth']['app'][$base_app]) &&
+                ($_SESSION['horde_auth']['app'][$base_app] == $entry)) {
+                $entry = null;
+            }
+        }
+
+        $_SESSION['horde_auth']['app'][$app] = $entry;
     }
 
     /**
@@ -1938,8 +1948,15 @@ class Horde_Registry
             return false;
         }
 
+        $base_app = $_SESSION['horde_auth']['credentials'];
         if (is_null($app)) {
-            $app = $_SESSION['horde_auth']['credentials'];
+            $app = $base_app;
+        }
+
+        if (empty($_SESSION['horde_auth']['app'][$app])) {
+            return ($base_app != $app)
+                ? $this->_getAuthCredentials($app)
+                : false;
         }
 
         $secret = $GLOBALS['injector']->getInstance('Horde_Secret');