feat: Integrate unlimited IP functionality into web panel
This commit is contained in:
@ -39,7 +39,7 @@ async def add_user_api(body: AddUserInputBody):
|
||||
detail=f"{str(e)}")
|
||||
|
||||
try:
|
||||
cli_api.add_user(body.username, body.traffic_limit, body.expiration_days, body.password, body.creation_date)
|
||||
cli_api.add_user(body.username, body.traffic_limit, body.expiration_days, body.password, body.creation_date, body.unlimited)
|
||||
return DetailResponse(detail=f'User {body.username} has been added.')
|
||||
except cli_api.CommandExecutionError as e:
|
||||
if "User already exists" in str(e):
|
||||
@ -98,7 +98,7 @@ async def edit_user_api(username: str, body: EditUserInputBody):
|
||||
cli_api.kick_user_by_name(username)
|
||||
cli_api.traffic_status(display_output=False)
|
||||
cli_api.edit_user(username, body.new_username, body.new_traffic_limit, body.new_expiration_days,
|
||||
body.renew_password, body.renew_creation_date, body.blocked)
|
||||
body.renew_password, body.renew_creation_date, body.blocked, body.unlimited_ip)
|
||||
return DetailResponse(detail=f'User {username} has been edited.')
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
|
||||
|
||||
@ -10,6 +10,7 @@ class User(BaseModel):
|
||||
expiry_date: str
|
||||
expiry_days: str
|
||||
enable: bool
|
||||
unlimited_ip: bool
|
||||
|
||||
@staticmethod
|
||||
def from_dict(username: str, user_data: dict):
|
||||
@ -58,6 +59,7 @@ class User(BaseModel):
|
||||
'expiry_date': display_expiry_date,
|
||||
'expiry_days': display_expiry_days,
|
||||
'enable': not user_data.get('blocked', False),
|
||||
'unlimited_ip': user_data.get('unlimited_user', False)
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user