simplify set_config

This commit is contained in:
Jörn-Michael Miehe 2022-03-28 02:38:52 +00:00
parent d9a9ad98f7
commit 799b2f7585

View file

@ -77,18 +77,13 @@ async def create_initial_admin(
}, },
) )
async def set_config( async def set_config(
new_config: Config, config: Config,
current_config: Config | None = Depends(Config.load),
_: User | None = Depends(get_current_user_if_admin), _: User | None = Depends(get_current_user_if_admin),
): ):
""" """
PUT ./config: Edit `kiwi-vpn` main config. PUT ./config: Edit `kiwi-vpn` main config.
""" """
# fail if not installed
if current_config is None:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST)
# update config file, reconnect to database # update config file, reconnect to database
new_config.save() config.save()
Connection.connect(current_config.db.uri) Connection.connect(config.db.uri)