From c6a3ffeb6161804a6a28f7b593159fecb6e2a9a6 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 8 Aug 2025 01:57:56 +0330 Subject: [PATCH] fix(api): allow setting unlimited values in edit_user --- core/cli_api.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/cli_api.py b/core/cli_api.py index 976bf2f..9eb6fc8 100644 --- a/core/cli_api.py +++ b/core/cli_api.py @@ -283,20 +283,22 @@ def edit_user(username: str, new_username: str | None, new_traffic_limit: int | ''' if not username: raise InvalidInputError('Error: username is required') - if not any([new_username, new_traffic_limit, new_expiration_days, renew_password, renew_creation_date, blocked is not None]): # type: ignore - raise InvalidInputError('Error: at least one option is required') - if new_traffic_limit is not None and new_traffic_limit <= 0: - raise InvalidInputError('Error: traffic limit must be greater than 0') - if new_expiration_days is not None and new_expiration_days <= 0: - raise InvalidInputError('Error: expiration days must be greater than 0') + + if new_traffic_limit is not None and new_traffic_limit < 0: + raise InvalidInputError('Error: traffic limit must be a non-negative number.') + if new_expiration_days is not None and new_expiration_days < 0: + raise InvalidInputError('Error: expiration days must be a non-negative number.') + if renew_password: password = generate_password() else: password = '' + if renew_creation_date: creation_date = datetime.now().strftime('%Y-%m-%d') else: creation_date = '' + command_args = [ 'bash', Command.EDIT_USER.value,