|
|
|
@ -101,6 +101,7 @@ class Rest extends WebService |
|
|
|
|
public const DELETE_USER = 'delete_user'; |
|
|
|
|
public const GET_USERS_API_KEYS = 'get_users_api_keys'; |
|
|
|
|
public const GET_USER_API_KEY = 'get_user_api_key'; |
|
|
|
|
public const GET_USER_LAST_CONNEXION = 'get_user_last_connexion'; |
|
|
|
|
public const GET_USER_SUB_GROUP = 'get_user_sub_group'; |
|
|
|
|
|
|
|
|
|
public const GET_COURSES = 'get_courses'; |
|
|
|
@ -3957,6 +3958,32 @@ class Rest extends WebService |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @throws Exception |
|
|
|
|
*/ |
|
|
|
|
public function getUserLastConnexion(string $username): array |
|
|
|
|
{ |
|
|
|
|
if (false === api_get_configuration_value('webservice_enable_adminonly_api') |
|
|
|
|
|| !UserManager::is_admin($this->user->getId()) |
|
|
|
|
) { |
|
|
|
|
self::throwNotAllowedException(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userInfo = api_get_user_info_from_username($username); |
|
|
|
|
|
|
|
|
|
if (empty($userInfo)) { |
|
|
|
|
throw new Exception(get_lang('UserNotFound')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$lastConnexionDate = Tracking::get_last_connection_date($userInfo['id']); |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
'id' => $userInfo['id'], |
|
|
|
|
'username' => $userInfo['username'], |
|
|
|
|
'last_connexion_date' => $lastConnexionDate, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function isAllowedByRequest(bool $inpersonate = false): bool |
|
|
|
|
{ |
|
|
|
|
$username = $_GET['username'] ?? null; |
|
|
|
|