@@ 55,6 55,16 @@ class AdminApiModule implements ServiceModuleInterface
fn(Request $request, UserInfo $userInfo): Response => new JsonResponse(self::extractConnectedUsers($this->connectionManager->get()))
);
+ $service->get(
+ '/v1/users',
+ fn(Request $request, UserInfo $userInfo): Response => new JsonResponse(['users' => self::extractUsers($this->storage->userList())])
+ );
+
+ $service->get(
+ '/v1/disabled_users',
+ fn(Request $request, UserInfo $userInfo): Response => new JsonResponse(['disabled_users' => self::extractDisabledUsers($this->storage->userList())])
+ );
+
$service->post(
'/v1/disable_user',
function (Request $request, UserInfo $userInfo): Response {
@@ 185,4 195,36 @@ class AdminApiModule implements ServiceModuleInterface
return $userList;
}
+
+ /**
+ * @param array<\Vpn\Portal\Http\UserInfo> $userList
+ *
+ * @return array<string>
+ */
+ private static function extractUsers(array $userList): array
+ {
+ $strUserList = [];
+ foreach ($userList as $userInfo) {
+ $strUserList[] = $userInfo->userId();
+ }
+
+ return $strUserList;
+ }
+
+ /**
+ * @param array<\Vpn\Portal\Http\UserInfo> $userList
+ *
+ * @return array<string>
+ */
+ private static function extractDisabledUsers(array $userList): array
+ {
+ $disabledUserList = [];
+ foreach ($userList as $userInfo) {
+ if ($userInfo->isDisabled()) {
+ $disabledUserList[] = $userInfo->userId();
+ }
+ }
+
+ return $disabledUserList;
+ }
}