]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/FKOAuthDataStore.php
Fix formatting in Model\Group
[friendica.git] / src / Network / FKOAuthDataStore.php
index 84d3b790ba1d5fa095010d393712300aa888ad12..d1f43172b651f2d4f40503417718987198e7b6ec 100644 (file)
@@ -10,8 +10,8 @@
 namespace Friendica\Network;
 
 use Friendica\Core\Config;
+use Friendica\Core\Logger;
 use Friendica\Database\DBA;
-use Friendica\Database\DBM;
 use OAuthConsumer;
 use OAuthDataStore;
 use OAuthToken;
@@ -19,8 +19,6 @@ use OAuthToken;
 define('REQUEST_TOKEN_DURATION', 300);
 define('ACCESS_TOKEN_DURATION', 31536000);
 
-require_once 'include/dba.php';
-
 /**
  * @brief OAuthDataStore class
  */
@@ -37,15 +35,16 @@ class FKOAuthDataStore extends OAuthDataStore
        /**
         * @param string $consumer_key key
         * @return mixed
+        * @throws \Exception
         */
        public function lookup_consumer($consumer_key)
        {
-               logger(__function__ . ":" . $consumer_key);
+               Logger::log(__function__ . ":" . $consumer_key);
 
                $s = DBA::select('clients', ['client_id', 'pw', 'redirect_uri'], ['client_id' => $consumer_key]);
                $r = DBA::toArray($s);
 
-               if (DBM::is_result($r)) {
+               if (DBA::isResult($r)) {
                        return new OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']);
                }
 
@@ -57,15 +56,16 @@ class FKOAuthDataStore extends OAuthDataStore
         * @param string $token_type type
         * @param string $token      token
         * @return mixed
+        * @throws \Exception
         */
        public function lookup_token($consumer, $token_type, $token)
        {
-               logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token);
+               Logger::log(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token);
 
                $s = DBA::select('tokens', ['id', 'secret', 'scope', 'expires', 'uid'], ['client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token]);
                $r = DBA::toArray($s);
 
-               if (DBM::is_result($r)) {
+               if (DBA::isResult($r)) {
                        $ot = new OAuthToken($r[0]['id'], $r[0]['secret']);
                        $ot->scope = $r[0]['scope'];
                        $ot->expires = $r[0]['expires'];
@@ -82,11 +82,12 @@ class FKOAuthDataStore extends OAuthDataStore
         * @param string $nonce     nonce
         * @param string $timestamp timestamp
         * @return mixed
+        * @throws \Exception
         */
        public function lookup_nonce($consumer, $token, $nonce, $timestamp)
        {
                $token = DBA::selectFirst('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp]);
-               if (DBM::is_result($token)) {
+               if (DBA::isResult($token)) {
                        return new OAuthToken($token['id'], $token['secret']);
                }
 
@@ -97,10 +98,11 @@ class FKOAuthDataStore extends OAuthDataStore
         * @param string $consumer consumer
         * @param string $callback optional, default null
         * @return mixed
+        * @throws \Exception
         */
        public function new_request_token($consumer, $callback = null)
        {
-               logger(__function__ . ":" . $consumer . ", " . $callback);
+               Logger::log(__function__ . ":" . $consumer . ", " . $callback);
                $key = self::genToken();
                $sec = self::genToken();
 
@@ -132,10 +134,11 @@ class FKOAuthDataStore extends OAuthDataStore
         * @param string $consumer consumer
         * @param string $verifier optional, defult null
         * @return object
+        * @throws HTTPException\InternalServerErrorException
         */
        public function new_access_token($token, $consumer, $verifier = null)
        {
-               logger(__function__ . ":" . $token . ", " . $consumer . ", " . $verifier);
+               Logger::log(__function__ . ":" . $token . ", " . $consumer . ", " . $verifier);
 
                // return a new access token attached to this consumer
                // for the user associated with this token if the request token
@@ -146,7 +149,7 @@ class FKOAuthDataStore extends OAuthDataStore
 
                // get user for this verifier
                $uverifier = Config::get("oauth", $verifier);
-               logger(__function__ . ":" . $verifier . "," . $uverifier);
+               Logger::log(__function__ . ":" . $verifier . "," . $uverifier);
 
                if (is_null($verifier) || ($uverifier !== false)) {
                        $key = self::genToken();