status code

This commit is contained in:
Valentin CZERYBA 2023-11-03 15:22:59 +01:00
parent 753f4ee087
commit ce0ba3e55b

View File

@ -146,7 +146,7 @@ async def update_users_me(current_user: Annotated[users.User, Depends(users_toke
return current_user return current_user
@router.put("/users", tags=["users"], response_model=users.User, status_code=status.HTTP_200_OK) @router.put("/users", tags=["users"], response_model=users.User, status_code=status.HTTP_200_OK)
async def update_users_id(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))], userSingle: users.UserIn | None = None): async def update_users_id(authorize: Annotated[bool, Depends(permissions_checker.PermissionChecker(roles=["Admin"]))], userSingle: users.UserIn | None = None, response: Response = Response):
if userSingle is None: if userSingle is None:
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
@ -156,7 +156,7 @@ async def update_users_id(authorize: Annotated[bool, Depends(permissions_checker
user = user_repository.find_one_by({"username": {'$eq': userSingle.username}}) user = user_repository.find_one_by({"username": {'$eq': userSingle.username}})
if user is None: if user is None:
Response.status_code = status.HTTP_201_CREATED response.status_code = status.HTTP_201_CREATED
user = users.User(username=userSingle.username, password=users_token.get_password_hash(userSingle.password), email=userSingle.email) user = users.User(username=userSingle.username, password=users_token.get_password_hash(userSingle.password), email=userSingle.email)
user.username = userSingle.username user.username = userSingle.username
user.password = users_token.get_password_hash(userSingle.password) user.password = users_token.get_password_hash(userSingle.password)