diff --git a/api/kiwi_vpn_api/routers/install.py b/api/kiwi_vpn_api/routers/install.py index 184b025..f6b9678 100644 --- a/api/kiwi_vpn_api/routers/install.py +++ b/api/kiwi_vpn_api/routers/install.py @@ -5,7 +5,7 @@ from secrets import token_hex from fastapi import APIRouter, Depends, HTTPException, status from peewee import Database -from ..config import CRYPT_CONTEXT, BaseConfig +from ..config import BaseConfig from ..db import Certificate, DistinguishedName, User, UserCapability router = APIRouter(prefix="/install") @@ -109,6 +109,7 @@ async def check_db( async def create_db( admin_name: str, admin_password: str, + config: BaseConfig = Depends(load_config), db: Database = Depends(connect_db), ): if await has_tables(db): @@ -116,8 +117,9 @@ async def create_db( db.create_tables([Certificate, DistinguishedName, User, UserCapability]) + cryptContext = await config.crypto.cryptContext admin = User.create( name=admin_name, - password=CRYPT_CONTEXT.hash(admin_password), + password=cryptContext.hash(admin_password), ) UserCapability.create(user=admin, capability="admin")