Improve error checking in listing users

This commit is contained in:
Sarina
2024-07-23 17:40:00 +03:30
parent f2c9cbf516
commit 69a205a487
2 changed files with 6 additions and 2 deletions

View File

@ -143,7 +143,11 @@ hysteria2_get_user_handler() {
}
hysteria2_list_users_handler() {
users_json=$(python3 $CLI_PATH list-users)
users_json=$(python3 $CLI_PATH list-users 2>/dev/null)
if [ $? -ne 0 ] || [ -z "$users_json" ]; then
echo -e "\033[0;31mError:\033[0m Failed to list users."
return 1
fi
users_array=($(echo "$users_json" | jq -r '.[] | .username'))
if [[ ${#users_array[@]} -eq 0 ]]; then