diff --git a/api/kiwi_vpn_api/config.py b/api/kiwi_vpn_api/config.py index 5f9fbfc..f6968f3 100644 --- a/api/kiwi_vpn_api/config.py +++ b/api/kiwi_vpn_api/config.py @@ -70,6 +70,6 @@ async def is_configured() -> bool: return Path(CONFIG_FILE).is_file() -async def get_config() -> BaseConfig: +async def get_current_config() -> BaseConfig: with open(CONFIG_FILE, "r") as kv: return BaseConfig.parse_obj(json.load(kv)) diff --git a/api/kiwi_vpn_api/routers/install.py b/api/kiwi_vpn_api/routers/install.py index 1c6be3b..a992d1a 100644 --- a/api/kiwi_vpn_api/routers/install.py +++ b/api/kiwi_vpn_api/routers/install.py @@ -3,8 +3,8 @@ from secrets import token_hex from fastapi import APIRouter, Depends, status from fastapi.responses import JSONResponse -from ..config import (CONFIG_FILE, CRYPT_CONTEXT, DB, BaseConfig, get_config, - get_default_config, is_configured) +from ..config import (CONFIG_FILE, CRYPT_CONTEXT, DB, BaseConfig, + get_current_config, get_default_config, is_configured) from ..db import Certificate, DistinguishedName, User, UserCapability router = APIRouter(prefix="/install") @@ -27,12 +27,11 @@ async def get_default_config(config: BaseConfig = Depends(get_default_config)): ) async def get_config( is_configured: bool = Depends(is_configured), - config: BaseConfig = Depends(get_config), ): if not is_configured: return JSONResponse(status_code=status.HTTP_404_NOT_FOUND) - return config + return await get_current_config() @router.put(