Skip to content

Commit c8ff566

Browse files
committed
Webservice: Add get_user_info_from_username WS (rename from get_user_from_username) - refs #6078
1 parent c19b19d commit c8ff566

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

main/inc/lib/webservices/Rest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Rest extends WebService
9292
public const DELETE_CAMPUS = 'delete_campus';
9393

9494
public const GET_USERS = 'get_users';
95+
public const GET_USER_INFO_FROM_USERNAME = 'get_user_info_from_username';
9596
public const USERNAME_EXIST = 'username_exist';
9697
public const SAVE_USER = 'save_user';
9798
public const SAVE_USER_GET_APIKEY = 'save_user_get_apikey';

main/webservices/api/v2.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,26 @@
548548
$data = $restApi->getUsersCampus($_POST);
549549
$restResponse->setData($data);
550550
break;
551+
case Rest::GET_USER_INFO_FROM_USERNAME:
552+
if (empty($_POST['loginname'])) {
553+
throw new Exception(get_lang('NoData'));
554+
}
555+
$item = api_get_user_info_from_username($_POST['loginname']);
556+
$userInfo = [
557+
'id' => $item['user_id'],
558+
'firstname' => $item['firstname'],
559+
'lastname' => $item['lastname'],
560+
'email' => $item['email'],
561+
'username' => $item['username'],
562+
'active' => $item['active'],
563+
];
564+
Event::addEvent(
565+
LOG_WS.$action,
566+
'username',
567+
Database::escape_string($_POST['loginname'])
568+
);
569+
$restResponse->setData($userInfo);
570+
break;
551571
case Rest::USERNAME_EXIST:
552572
Event::addEvent(LOG_WS.$action, 'username', $_POST['loginname']);
553573
$data = $restApi->usernameExist($_POST['loginname']);

0 commit comments

Comments
 (0)