feat: Add password editing to user modal
This commit is contained in:
19
core/cli.py
19
core/cli.py
@ -157,19 +157,30 @@ def bulk_user_add(traffic_gb: float, expiration_days: int, count: int, prefix: s
|
||||
@cli.command('edit-user')
|
||||
@click.option('--username', '-u', required=True, help='Username for the user to edit', type=str)
|
||||
@click.option('--new-username', '-nu', required=False, help='New username for the user', type=str)
|
||||
@click.option('--new-password', '-np', required=False, help='New password for the user. If not set, use --renew-password to generate one.', type=str)
|
||||
@click.option('--new-traffic-limit', '-nt', required=False, help='Traffic limit for the new user in GB', type=int)
|
||||
@click.option('--new-expiration-days', '-ne', required=False, help='Expiration days for the new user', type=int)
|
||||
@click.option('--renew-password', '-rp', is_flag=True, help='Renew password for the user')
|
||||
@click.option('--renew-password', '-rp', is_flag=True, help='Renew password for the user (generates a random one)')
|
||||
@click.option('--renew-creation-date', '-rc', is_flag=True, help='Renew creation date for the user')
|
||||
@click.option('--blocked/--unblocked', 'blocked', '-b', default=None, help='Block or unblock the user.')
|
||||
@click.option('--unlimited-ip/--limited-ip', 'unlimited_ip', default=None, help='Set user to be exempt from or subject to IP limits.')
|
||||
@click.option('--note', '-n', required=False, help='New note for the user.', type=str)
|
||||
def edit_user(username: str, new_username: str, new_traffic_limit: int, new_expiration_days: int, renew_password: bool, renew_creation_date: bool, blocked: bool | None, unlimited_ip: bool | None, note: str | None):
|
||||
def edit_user(username: str, new_username: str, new_password: str, new_traffic_limit: int, new_expiration_days: int, renew_password: bool, renew_creation_date: bool, blocked: bool | None, unlimited_ip: bool | None, note: str | None):
|
||||
try:
|
||||
cli_api.kick_users_by_name(username)
|
||||
cli_api.traffic_status(display_output=False)
|
||||
cli_api.edit_user(username, new_username, new_traffic_limit, new_expiration_days,
|
||||
renew_password, renew_creation_date, blocked, unlimited_ip, note)
|
||||
cli_api.edit_user(
|
||||
username=username,
|
||||
new_username=new_username,
|
||||
new_password=new_password,
|
||||
new_traffic_limit=new_traffic_limit,
|
||||
new_expiration_days=new_expiration_days,
|
||||
renew_password=renew_password,
|
||||
renew_creation_date=renew_creation_date,
|
||||
blocked=blocked,
|
||||
unlimited_ip=unlimited_ip,
|
||||
note=note
|
||||
)
|
||||
click.echo(f"User '{username}' updated successfully.")
|
||||
except Exception as e:
|
||||
click.echo(f'{e}', err=True)
|
||||
|
||||
Reference in New Issue
Block a user