Fix : add and edit user exists

This commit is contained in:
Whispering Wind
2025-01-26 00:50:31 +03:30
committed by GitHub
parent 34a2e796db
commit 20a9ae694a

View File

@ -37,7 +37,7 @@ hysteria2_add_user_handler() {
read -p "Enter the username: " username read -p "Enter the username: " username
if [[ "$username" =~ ^[a-zA-Z0-9]+$ ]]; then if [[ "$username" =~ ^[a-zA-Z0-9]+$ ]]; then
if python3 $CLI_PATH get-user --username "$username" > /dev/null 2>&1; then if [[ -n $(python3 $CLI_PATH get-user -u "$username") ]]; then
echo -e "${red}Error:${NC} Username already exists. Please choose another username." echo -e "${red}Error:${NC} Username already exists. Please choose another username."
else else
break break
@ -82,8 +82,9 @@ hysteria2_edit_user() {
prompt_for_input "Enter the username you want to edit: " '^[a-zA-Z0-9]+$' '' username prompt_for_input "Enter the username you want to edit: " '^[a-zA-Z0-9]+$' '' username
# Check if user exists # Check if user exists
if ! python3 $CLI_PATH get-user --username "$username" > /dev/null 2>&1; then user_exists_output=$(python3 $CLI_PATH get-user -u "$username" 2>&1)
echo -e "${red}Error:${NC} User '$username' not found." if [[ -z "$user_exists_output" ]]; then
echo -e "${red}Error:${NC} User '$username' not found or an error occurred."
return 1 return 1
fi fi