diff --git a/api/kiwi_vpn_api/routers/user.py b/api/kiwi_vpn_api/routers/user.py index 1db468c..6beafb0 100644 --- a/api/kiwi_vpn_api/routers/user.py +++ b/api/kiwi_vpn_api/routers/user.py @@ -76,24 +76,26 @@ async def get_current_user( status.HTTP_403_FORBIDDEN: Responses.NEEDS_ADMIN, status.HTTP_409_CONFLICT: Responses.ENTRY_EXISTS, }, - response_model=User, + response_model=UserRead, ) async def add_user( user: UserCreate, _: User = Depends(get_current_user_if_admin), -): +) -> User: """ POST ./: Create a new user in the database. """ # actually create the new user new_user = User.create(**user.dict()) - new_user.set_capabilities([UserCapabilityType.login]) # fail if creation was unsuccessful if new_user is None: raise HTTPException(status_code=status.HTTP_409_CONFLICT) + new_user.set_capabilities([UserCapabilityType.login]) + new_user.update() + # return the created user on success return new_user