simplify set_config
This commit is contained in:
parent
d9a9ad98f7
commit
799b2f7585
1 changed files with 3 additions and 8 deletions
|
@ -77,18 +77,13 @@ async def create_initial_admin(
|
|||
},
|
||||
)
|
||||
async def set_config(
|
||||
new_config: Config,
|
||||
current_config: Config | None = Depends(Config.load),
|
||||
config: Config,
|
||||
_: User | None = Depends(get_current_user_if_admin),
|
||||
):
|
||||
"""
|
||||
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
|
||||
new_config.save()
|
||||
Connection.connect(current_config.db.uri)
|
||||
config.save()
|
||||
Connection.connect(config.db.uri)
|
||||
|
|
Loading…
Reference in a new issue