mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-20 15:21:30 +02:00
- Added `clean_name` function to `validation.py` for name validation with max length. - Simplified docstrings in `dnsx` client, parser, and service files for clarity. - Enhanced error handling in `ViewDNSService` to prevent disabling keys on rate limits. - Improved WHOIS service to handle concurrent inserts gracefully with integrity checks. - Updated `Settings` class in worker config to inherit from `BaseAppSettings`. - Added new dependencies in `pyproject.toml` for `apprise` and `cryptography`.
27 lines
880 B
Python
27 lines
880 B
Python
from sqlmodel import select
|
|
|
|
from app.config import settings
|
|
from app.core.database import async_db_session
|
|
from app.core.security import hash_password
|
|
from shared.logging import get_logger
|
|
from shared.models.user import User
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
async def create_initial_admin() -> None:
|
|
async with async_db_session() as session:
|
|
result = await session.execute(select(User).limit(1))
|
|
existing_user = result.scalar_one_or_none()
|
|
|
|
if existing_user is None:
|
|
admin = User(
|
|
email=settings.ADMIN_EMAIL,
|
|
username=settings.ADMIN_USERNAME,
|
|
hashed_password=hash_password(settings.ADMIN_PASSWORD),
|
|
is_superuser=True,
|
|
)
|
|
session.add(admin)
|
|
await session.commit()
|
|
logger.info(f"Initial admin created: {settings.ADMIN_USERNAME}")
|