From 799b2f7585c97adea0a5ed8dc00b26cb39a5561a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?=
 <40151420+ldericher@users.noreply.github.com>
Date: Mon, 28 Mar 2022 02:38:52 +0000
Subject: [PATCH] simplify set_config

---
 api/kiwi_vpn_api/routers/admin.py | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/api/kiwi_vpn_api/routers/admin.py b/api/kiwi_vpn_api/routers/admin.py
index 64c7307..f0ee109 100644
--- a/api/kiwi_vpn_api/routers/admin.py
+++ b/api/kiwi_vpn_api/routers/admin.py
@@ -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)