Rearranged function order

This commit is contained in:
Michael 2021-06-08 08:56:01 +00:00
parent 11c8dfe73a
commit 95cac04540
2 changed files with 52 additions and 52 deletions

View file

@ -38,6 +38,25 @@ class BasicAuth
*/
protected static $current_token = [];
/**
* Get current user id, returns 0 if $login is set to false and not logged in.
* When $login is true, the execution will stop when not logged in.
*
* @param bool $login Perform a login request if "true"
*
* @return int User ID
*/
public static function getCurrentUserID(bool $login = true)
{
if (empty(self::$current_user_id)) {
api_login(DI::app(), $login);
self::$current_user_id = api_user();
}
return (int)self::$current_user_id;
}
/**
* Fetch a dummy application token
*
@ -66,23 +85,4 @@ class BasicAuth
return self::$current_token;
}
/**
* Get current user id, returns 0 if $login is set to false and not logged in.
* When $login is true, the execution will stop when not logged in.
*
* @param bool $login Perform a login request if "true"
*
* @return int User ID
*/
public static function getCurrentUserID(bool $login = true)
{
if (empty(self::$current_user_id)) {
api_login(DI::app(), $login);
self::$current_user_id = api_user();
}
return (int)self::$current_user_id;
}
}