mirror of
https://github.com/friendica/friendica
synced 2024-11-19 11:03:40 +00:00
Formatting FKOauthDataStore
This commit is contained in:
parent
2978b1eef0
commit
910d3f7b5f
1 changed files with 11 additions and 11 deletions
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file src/Protocol/FKOAuthDataStore.php
|
* @file src/Protocol/FKOAuthDataStore.php
|
||||||
* OAuth server
|
* OAuth server
|
||||||
* Based on oauth2-php <http://code.google.com/p/oauth2-php/>
|
* Based on oauth2-php <http://code.google.com/p/oauth2-php/>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Network;
|
namespace Friendica\Network;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
@ -41,7 +43,7 @@ class FKOAuthDataStore extends OAuthDataStore
|
||||||
*/
|
*/
|
||||||
public function lookup_consumer($consumer_key)
|
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));
|
$s = dba::select('clients', array('client_id', 'pw', 'redirect_uri'), array('client_id' => $consumer_key));
|
||||||
$r = dba::inArray($s);
|
$r = dba::inArray($s);
|
||||||
|
@ -61,7 +63,7 @@ class FKOAuthDataStore extends OAuthDataStore
|
||||||
*/
|
*/
|
||||||
public function lookup_token($consumer, $token_type, $token)
|
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));
|
$s = dba::select('tokens', array('id', 'secret', 'scope', 'expires', 'uid'), array('client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token));
|
||||||
$r = dba::inArray($s);
|
$r = dba::inArray($s);
|
||||||
|
@ -102,7 +104,7 @@ class FKOAuthDataStore extends OAuthDataStore
|
||||||
*/
|
*/
|
||||||
public function new_request_token($consumer, $callback = null)
|
public function new_request_token($consumer, $callback = null)
|
||||||
{
|
{
|
||||||
logger(__function__.":".$consumer.", ". $callback);
|
logger(__function__ . ":" . $consumer . ", " . $callback);
|
||||||
$key = self::genToken();
|
$key = self::genToken();
|
||||||
$sec = self::genToken();
|
$sec = self::genToken();
|
||||||
|
|
||||||
|
@ -137,7 +139,7 @@ class FKOAuthDataStore extends OAuthDataStore
|
||||||
*/
|
*/
|
||||||
public function new_access_token($token, $consumer, $verifier = null)
|
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
|
// return a new access token attached to this consumer
|
||||||
// for the user associated with this token if the request token
|
// for the user associated with this token if the request token
|
||||||
|
@ -148,9 +150,9 @@ class FKOAuthDataStore extends OAuthDataStore
|
||||||
|
|
||||||
// get user for this verifier
|
// get user for this verifier
|
||||||
$uverifier = Config::get("oauth", $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();
|
$key = self::genToken();
|
||||||
$sec = self::genToken();
|
$sec = self::genToken();
|
||||||
$r = dba::insert(
|
$r = dba::insert(
|
||||||
|
@ -169,10 +171,8 @@ class FKOAuthDataStore extends OAuthDataStore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dba::delete('tokens', array('id' => $token->key));
|
dba::delete('tokens', array('id' => $token->key));
|
||||||
|
|
||||||
|
|
||||||
if (!is_null($ret) && !is_null($uverifier)) {
|
if (!is_null($ret) && !is_null($uverifier)) {
|
||||||
Config::delete("oauth", $verifier);
|
Config::delete("oauth", $verifier);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue