]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/apignusocialoauthdatastore.php
Merge remote-tracking branch 'upstream/nightly' into nightly
[quix0rs-gnu-social.git] / lib / apignusocialoauthdatastore.php
index d3eec55c9e19b2da015629ff4708519dce82a40d..6f4403dec73860aaebf9fbb1e00776e85703cf50 100644 (file)
@@ -26,20 +26,20 @@ require_once 'OAuth.php';
  */
 class ApiGNUsocialOAuthDataStore extends OAuthDataStore
 {
-    function lookup_consumer($consumerKey)
+    function lookup_consumer($consumer_key)
     {
-        $con = Consumer::getKV('consumer_key', $consumerKey);
+        $con = Consumer::getKV('consumer_key', $consumer_key);
 
-        if (!$con) {
+        if (!$con instanceof Consumer) {
 
             // Create an anon consumer and anon application if one
             // doesn't exist already
-            if ($consumerKey == 'anonymous') {
+            if ($consumer_key == 'anonymous') {
 
                 common_debug("API OAuth - creating anonymous consumer");
                 $con = new Consumer();
-                $con->consumer_key    = $consumerKey;
-                $con->consumer_secret = $consumerKey;
+                $con->consumer_key    = $consumer_key;
+                $con->consumer_secret = $consumer_key;
                 $con->created         = common_sql_now();
 
                 $result = $con->insert();
@@ -264,8 +264,8 @@ class ApiGNUsocialOAuthDataStore extends OAuthDataStore
         $at = new Token();
 
         $at->consumer_key      = $consumer->key;
-        $at->tok               = common_good_rand(16);
-        $at->secret            = common_good_rand(16);
+        $at->tok               = common_random_hexstr(16);
+        $at->secret            = common_random_hexstr(16);
         $at->type              = 1; // access
         $at->verifier          = $verifier;
         $at->verified_callback = $rt->verified_callback; // 1.0a
@@ -388,12 +388,12 @@ class ApiGNUsocialOAuthDataStore extends OAuthDataStore
      *
      * @return OAuthToken   $token a new unauthorized OAuth request token
      */
-    function new_request_token($consumer, $callback)
+    function new_request_token($consumer, $callback = null)
     {
         $t = new Token();
         $t->consumer_key = $consumer->key;
-        $t->tok = common_good_rand(16);
-        $t->secret = common_good_rand(16);
+        $t->tok = common_random_hexstr(16);
+        $t->secret = common_random_hexstr(16);
         $t->type = 0; // request
         $t->state = 0; // unauthorized
         $t->verified_callback = $callback;
@@ -402,7 +402,7 @@ class ApiGNUsocialOAuthDataStore extends OAuthDataStore
             // six digit pin
             $t->verifier = mt_rand(0, 9999999);
         } else {
-            $t->verifier = common_good_rand(8);
+            $t->verifier = common_random_hexstr(8);
         }
 
         $t->created = common_sql_now();
@@ -473,13 +473,13 @@ class ApiGNUsocialOAuthDataStore extends OAuthDataStore
      * @param type $token_key
      * @return OAuthToken
      */
-    function lookup_token($consumer, $token_type, $token_key)
+    function lookup_token($consumer, $token_type, $token)
     {
         $t = new Token();
         if (!is_null($consumer)) {
             $t->consumer_key = $consumer->key;
         }
-        $t->tok = $token_key;
+        $t->tok = $token;
         $t->type = ($token_type == 'access') ? 1 : 0;
         if ($t->find(true)) {
             return new OAuthToken($t->tok, $t->secret);