From 900131fae843202f8c1cccf30b2bf3aa68c87fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 19 Mar 2022 03:31:41 +0000 Subject: [PATCH] add_user data into req body --- api/kiwi_vpn_api/routers/admin.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/api/kiwi_vpn_api/routers/admin.py b/api/kiwi_vpn_api/routers/admin.py index 07c98a6..7f98bc9 100644 --- a/api/kiwi_vpn_api/routers/admin.py +++ b/api/kiwi_vpn_api/routers/admin.py @@ -48,20 +48,17 @@ async def set_config( }, ) async def add_user( - user_name: str, - user_password: str, + user: schemas.UserCreate, current_config: Config | None = Depends(Config.load), db: Session | None = Depends(Connection.get), ): if current_config is None: raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST) + user.capabilities.append("admin") + schemas.User.create( db=db, - user=schemas.UserCreate( - name=user_name, - password=user_password, - capabilities=["admin"], - ), + user=user, crypt_context=await current_config.crypto.crypt_context, )