diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index 27aa46d99f..424b6391ee 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -1,10 +1,12 @@ * */ + namespace Friendica\Network; use Friendica\App; @@ -41,8 +43,8 @@ class FKOAuthDataStore extends OAuthDataStore */ public function lookup_consumer($consumer_key) { - logger(__function__.":".$consumer_key); - + logger(__function__ . ":" . $consumer_key); + $s = dba::select('clients', array('client_id', 'pw', 'redirect_uri'), array('client_id' => $consumer_key)); $r = dba::inArray($s); @@ -61,8 +63,8 @@ class FKOAuthDataStore extends OAuthDataStore */ public function lookup_token($consumer, $token_type, $token) { - logger(__function__.":".$consumer.", ". $token_type.", ".$token); - + logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token); + $s = dba::select('tokens', array('id', 'secret', 'scope', 'expires', 'uid'), array('client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token)); $r = dba::inArray($s); @@ -87,7 +89,7 @@ class FKOAuthDataStore extends OAuthDataStore public function lookup_nonce($consumer, $token, $nonce, $timestamp) { $r = dba::select('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp], ['limit' => 1]); - + if (DBM::is_result($r)) { return new \OAuthToken($r['id'], $r['secret']); } @@ -102,7 +104,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function new_request_token($consumer, $callback = null) { - logger(__function__.":".$consumer.", ". $callback); + logger(__function__ . ":" . $consumer . ", " . $callback); $key = self::genToken(); $sec = self::genToken(); @@ -137,7 +139,7 @@ class FKOAuthDataStore extends OAuthDataStore */ public function new_access_token($token, $consumer, $verifier = null) { - logger(__function__.":".$token.", ". $consumer.", ". $verifier); + logger(__function__ . ":" . $token . ", " . $consumer . ", " . $verifier); // return a new access token attached to this consumer // for the user associated with this token if the request token @@ -148,9 +150,9 @@ class FKOAuthDataStore extends OAuthDataStore // get user for this verifier $uverifier = Config::get("oauth", $verifier); - logger(__function__.":".$verifier.",".$uverifier); + logger(__function__ . ":" . $verifier . "," . $uverifier); - if (is_null($verifier) || ($uverifier!==false)) { + if (is_null($verifier) || ($uverifier !== false)) { $key = self::genToken(); $sec = self::genToken(); $r = dba::insert( @@ -169,10 +171,8 @@ class FKOAuthDataStore extends OAuthDataStore } } - dba::delete('tokens', array('id' => $token->key)); - if (!is_null($ret) && !is_null($uverifier)) { Config::delete("oauth", $verifier); }