Fix logic in setUser for not setting cookies
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 5 Mar 2009 01:29:50 +0000 (20:29 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 5 Mar 2009 01:33:55 +0000 (20:33 -0500)
Move getLoggedInUser() method to the Auth class even though it calls the
'Users.getLoggedInUsers' api method. Makes more sense as an Auth method.

framework/Service_Facebook/lib/Horde/Service/Facebook/Auth.php
framework/Service_Facebook/lib/Horde/Service/Facebook/Users.php

index cccfb13..6a1bbc7 100644 (file)
@@ -421,8 +421,8 @@ class Horde_Service_Facebook_Auth
      */
     public function setUser($user, $sessionKey, $expires = null, $no_cookie = false)
     {
-        if ($no_cookie || !$this->_request->getCookie($this->_facebook->apiKey . '_user') ||
-            $this->_request->getCookie($this->_facebook->apiKey . '_user') != $user) {
+        if (!$no_cookie && (!$this->_request->getCookie($this->_facebook->apiKey . '_user') ||
+            $this->_request->getCookie($this->_facebook->apiKey . '_user') != $user)) {
 
             $this->setCookies($user, $sessionKey, $expires);
         }
@@ -470,4 +470,22 @@ class Horde_Service_Facebook_Auth
         $this->expireSession();
 
     }
+
+    /**
+     * Returns the user corresponding to the current session object.
+     *
+     * @throws Horde_Service_Facebook_Exception
+     * @return integer  User id
+     */
+    public function &getLoggedInUser()
+    {
+        if (!$this->getSessionKey()) {
+            throw new Horde_Service_Facebook_Exception('users.getLoggedInUser requires a session_key',
+                Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
+        }
+
+        return $this->_facebook->callMethod('facebook.users.getLoggedInUser',
+            array('session_key' => $this->getSessionKey()));
+    }
+
 }
\ No newline at end of file
index 9fb9ab9..b441f4a 100644 (file)
@@ -48,23 +48,6 @@ class Horde_Service_Facebook_Users extends Horde_Service_Facebook_Base
     }
 
     /**
-    * Returns the user corresponding to the current session object.
-    *
-    * @throws Horde_Service_Facebook_Exception
-    * @return integer  User id
-    */
-    public function &getLoggedInUser()
-    {
-        if (!$this->_facebook->auth->getSessionKey()) {
-            throw new Horde_Service_Facebook_Exception('users.getLoggedInUser requires a session_key',
-                Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
-        }
-
-        return $this->_facebook->callMethod('facebook.users.getLoggedInUser',
-            array('session_key' => $this->_facebook->auth->getSessionKey()));
-    }
-
-    /**
      * Returns 1 if the user has the specified permission, 0 otherwise.
      * http://wiki.developers.facebook.com/index.php/Users.hasAppPermission
      *