add routers usersé

This commit is contained in:
Valentin CZERYBA 2023-10-27 23:50:35 +02:00
parent 4e2cf12c3b
commit 4059411828

View File

@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends, HTTPException, status from fastapi import APIRouter, Depends, HTTPException, status, Response
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
from datetime import datetime from datetime import datetime
from ..dependencies import users_token, permissions_checker, database from ..dependencies import users_token, permissions_checker, database
@ -104,8 +104,8 @@ 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() 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)
user.roles = userSingle.roles user.roles = userSingle.roles