Fix Edit user

This commit is contained in:
Whispering Wind
2024-08-01 23:25:03 +03:30
committed by GitHub
parent ada839714d
commit 1075a3616b

26
menu.sh
View File

@ -83,7 +83,7 @@ hysteria2_edit_user() {
# Prompt for new expiration days # Prompt for new expiration days
prompt_for_input "Enter the new expiration days (leave empty to keep the current expiration days): " '^[0-9]*$' '' new_expiration_days prompt_for_input "Enter the new expiration days (leave empty to keep the current expiration days): " '^[0-9]*$' '' new_expiration_days
# Prompt for renewing password # Determine if we need to renew password
while true; do while true; do
read -p "Do you want to generate a new password? (y/n): " renew_password read -p "Do you want to generate a new password? (y/n): " renew_password
case "$renew_password" in case "$renew_password" in
@ -93,7 +93,7 @@ hysteria2_edit_user() {
esac esac
done done
# Prompt for renewing creation date # Determine if we need to renew creation date
while true; do while true; do
read -p "Do you want to generate a new creation date? (y/n): " renew_creation_date read -p "Do you want to generate a new creation date? (y/n): " renew_creation_date
case "$renew_creation_date" in case "$renew_creation_date" in
@ -103,7 +103,7 @@ hysteria2_edit_user() {
esac esac
done done
# Prompt for blocking user # Determine if user should be blocked
while true; do while true; do
read -p "Do you want to block the user? (y/n): " block_user read -p "Do you want to block the user? (y/n): " block_user
case "$block_user" in case "$block_user" in
@ -113,15 +113,17 @@ hysteria2_edit_user() {
esac esac
done done
# Call the edit-user script with appropriate flags # Construct the arguments for the edit-user command
python3 $CLI_PATH edit-user \ args=()
--username "$username" \ if [[ -n "$new_username" ]]; then args+=("--new-username" "$new_username"); fi
${new_username:+--new-username "$new_username"} \ if [[ -n "$new_traffic_limit_GB" ]]; then args+=("--new-traffic-limit" "$new_traffic_limit_GB"); fi
${new_traffic_limit_GB:+--new-traffic-limit "$new_traffic_limit_GB"} \ if [[ -n "$new_expiration_days" ]]; then args+=("--new-expiration-days" "$new_expiration_days"); fi
${new_expiration_days:+--new-expiration-days "$new_expiration_days"} \ if [[ "$renew_password" == "true" ]]; then args+=("--renew-password"); fi
${renew_password:+--renew-password} \ if [[ "$renew_creation_date" == "true" ]]; then args+=("--renew-creation-date"); fi
${renew_creation_date:+--renew-creation-date} \ if [[ "$blocked" == "true" ]]; then args+=("--blocked"); fi
${blocked:+--blocked}
# Call the edit-user script with the constructed arguments
python3 $CLI_PATH edit-user --username "$username" "${args[@]}"
} }
hysteria2_remove_user_handler() { hysteria2_remove_user_handler() {