WIP: Custom exceptions handling and new models

This commit is contained in:
2023-02-16 14:11:29 +01:00
parent dddb5dbc12
commit 873e506c7d
7 changed files with 147 additions and 37 deletions

View File

@@ -50,7 +50,7 @@ if configGet("registration_requires_confirmation") is True:
return UJSONResponse( {"detail": configGet("email_confirmed", "messages")} )
if configGet("registration_enabled") is True:
@app.post("/users")
@app.post("/users", status_code=HTTP_204_NO_CONTENT)
async def user_create(user: str = Form(), email: str = Form(), password: str = Form()):
if col_users.find_one( {"user": user} ) is not None:
raise HTTPException(HTTP_406_NOT_ACCEPTABLE, detail=configGet("user_already_exists", "messages"))
@@ -60,7 +60,7 @@ if configGet("registration_enabled") is True:
return Response(status_code=HTTP_204_NO_CONTENT)
@app.delete("/users/me/")
@app.delete("/users/me/", status_code=HTTP_204_NO_CONTENT)
async def user_delete(password: str = Form(), current_user: User = Depends(get_current_active_user)):
user = get_user(current_user.user)
if not user: