Improve user reset API

This commit is contained in:
Whispering Wind
2025-04-14 12:22:42 +03:30
committed by GitHub
parent 3384095d9e
commit 49b9580b60

View File

@ -137,8 +137,14 @@ async def reset_user_api(username: str):
HTTPException: if an error occurs while resetting the user.
"""
try:
user = cli_api.get_user(username)
if not user:
raise HTTPException(status_code=404, detail=f'User {username} not found.')
cli_api.reset_user(username)
return DetailResponse(detail=f'User {username} has been reset.')
except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')