mirror of
https://github.com/friendica/friendica
synced 2025-04-19 06:30:10 +00:00
API: New function to fetch current user id
This commit is contained in:
parent
4395f73d1e
commit
10a6f0a98f
2 changed files with 27 additions and 1 deletions
|
@ -91,6 +91,22 @@ class BaseApi extends BaseModule
|
|||
return (bool)self::$current_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current user id, returns 0 if not logged in
|
||||
*
|
||||
* @return int User ID
|
||||
*/
|
||||
protected static function getCurrentUserID()
|
||||
{
|
||||
if (is_null(self::$current_user_id)) {
|
||||
api_login(DI::app(), false);
|
||||
|
||||
self::$current_user_id = api_user();
|
||||
}
|
||||
|
||||
return (int)self::$current_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user info array.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue