add_user data into req body

This commit is contained in:
Jörn-Michael Miehe 2022-03-19 03:31:41 +00:00
parent d66ce5a026
commit 900131fae8

View file

@ -48,20 +48,17 @@ async def set_config(
}, },
) )
async def add_user( async def add_user(
user_name: str, user: schemas.UserCreate,
user_password: str,
current_config: Config | None = Depends(Config.load), current_config: Config | None = Depends(Config.load),
db: Session | None = Depends(Connection.get), db: Session | None = Depends(Connection.get),
): ):
if current_config is None: if current_config is None:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST) raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST)
user.capabilities.append("admin")
schemas.User.create( schemas.User.create(
db=db, db=db,
user=schemas.UserCreate( user=user,
name=user_name,
password=user_password,
capabilities=["admin"],
),
crypt_context=await current_config.crypto.crypt_context, crypt_context=await current_config.crypto.crypt_context,
) )