mirror of
https://github.com/friendica/friendica
synced 2025-05-21 15:04:12 +02:00
Rearranged function order
This commit is contained in:
parent
11c8dfe73a
commit
95cac04540
2 changed files with 52 additions and 52 deletions
|
@ -45,6 +45,39 @@ class OAuth
|
|||
*/
|
||||
protected static $current_token = [];
|
||||
|
||||
/**
|
||||
* Get current user id, returns 0 if not logged in
|
||||
*
|
||||
* @return int User ID
|
||||
*/
|
||||
public static function getCurrentUserID()
|
||||
{
|
||||
if (empty(self::$current_user_id)) {
|
||||
$token = self::getCurrentApplicationToken();
|
||||
if (!empty($token['uid'])) {
|
||||
self::$current_user_id = $token['uid'];
|
||||
} else {
|
||||
self::$current_user_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (int)self::$current_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current application token
|
||||
*
|
||||
* @return array token
|
||||
*/
|
||||
public static function getCurrentApplicationToken()
|
||||
{
|
||||
if (empty(self::$current_token)) {
|
||||
self::$current_token = self::getTokenByBearer();
|
||||
}
|
||||
|
||||
return self::$current_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the provided scope does exist
|
||||
*
|
||||
|
@ -74,39 +107,6 @@ class OAuth
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current application token
|
||||
*
|
||||
* @return array token
|
||||
*/
|
||||
public static function getCurrentApplicationToken()
|
||||
{
|
||||
if (empty(self::$current_token)) {
|
||||
self::$current_token = self::getTokenByBearer();
|
||||
}
|
||||
|
||||
return self::$current_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user id, returns 0 if not logged in
|
||||
*
|
||||
* @return int User ID
|
||||
*/
|
||||
public static function getCurrentUserID()
|
||||
{
|
||||
if (empty(self::$current_user_id)) {
|
||||
$token = self::getCurrentApplicationToken();
|
||||
if (!empty($token['uid'])) {
|
||||
self::$current_user_id = $token['uid'];
|
||||
} else {
|
||||
self::$current_user_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (int)self::$current_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user token via the Bearer token
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue