]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
- Had to remove checking read vs. read-write in OAuth authenticated methods
authorZach Copley <zach@status.net>
Thu, 14 Jan 2010 02:38:01 +0000 (02:38 +0000)
committerZach Copley <zach@status.net>
Mon, 25 Jan 2010 00:51:56 +0000 (00:51 +0000)
- Will now pick up source attr from OAuth app

actions/apiaccountverifycredentials.php
actions/apistatusesupdate.php
lib/apiauth.php

index 08b201dbffdeec72f25c0089369c92e8268ab501..1095d5162634f312772ce78e4e533dc2a2eaf00a 100644 (file)
@@ -82,4 +82,18 @@ class ApiAccountVerifyCredentialsAction extends ApiAuthAction
 
     }
 
+    /**
+     * Is this action read only?
+     *
+     * @param array $args other arguments
+     * 
+     * @return boolean true
+     *
+     **/
+    
+    function isReadOnly($args)
+    {
+        return true;
+    }
+    
 }
index f594bbf393626ffa67cccc8d5806ea9629df864a..f8bf7cf874d0a811b2e600030cd57d4f173b4d19 100644 (file)
@@ -85,6 +85,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction
         $this->lat    = $this->trimmed('lat');
         $this->lon    = $this->trimmed('long');
 
+        // try to set the source attr from OAuth app
+        if (empty($this->source)) {
+            $this->source = $this->oauth_source;
+        }
+
         if (empty($this->source) || in_array($this->source, self::$reserved_sources)) {
             $this->source = 'api';
         }
index f513ed2c9a02af77cf7595172efdd83170db268f..37070d212fc5c6f40e309e2a3393a934fcd79295 100644 (file)
@@ -55,6 +55,7 @@ class ApiAuthAction extends ApiAction
 {
     var $access_token;
     var $oauth_access_type;
+    var $oauth_source;
 
     /**
      * Take arguments for running, and output basic auth header if needed
@@ -90,13 +91,6 @@ class ApiAuthAction extends ApiAction
     function handle($args)
     {
         parent::handle($args);
-
-        if ($this->isReadOnly($args) == false) {
-            if ($this->access == self::READ_ONLY) {
-                $this->clientError(_('API method requires write access.'), 401);
-                exit();
-            }
-        }
     }
 
     function checkOAuthRequest()
@@ -116,8 +110,6 @@ class ApiAuthAction extends ApiAction
             $req  = OAuthRequest::from_request();
             $server->verify_request($req);
 
-            common_debug("Good OAuth request!");
-
             $app = Oauth_application::getByConsumerKey($this->consumer_key);
 
             if (empty($app)) {
@@ -129,6 +121,10 @@ class ApiAuthAction extends ApiAction
                 throw new OAuthException('No application for that consumer key.');
             }
 
+            // set the source attr
+
+            $this->oauth_source = $app->name;
+
             $appUser = Oauth_application_user::staticGet('token',
                                                          $this->access_token);