From 49b9580b6074dafb52f62ba3719e65b942509ead Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:22:42 +0330 Subject: [PATCH] Improve user reset API --- core/scripts/webpanel/routers/api/v1/user.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/scripts/webpanel/routers/api/v1/user.py b/core/scripts/webpanel/routers/api/v1/user.py index 51e987e..828ceb3 100644 --- a/core/scripts/webpanel/routers/api/v1/user.py +++ b/core/scripts/webpanel/routers/api/v1/user.py @@ -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)}')