Fixed auth check and conftest

This commit is contained in:
JesseFPV
2026-01-21 15:36:39 +01:00
parent deeaabfa8d
commit 6e5cc55190
2 changed files with 8 additions and 3 deletions
+7 -3
View File
@@ -78,9 +78,13 @@ async def authenticate_user(db: AsyncSession, username: str, password: str) -> U
async def is_auth_enabled(db: AsyncSession) -> bool:
"""Check if authentication is enabled."""
result = await db.execute(select(Settings).where(Settings.key == "auth_enabled"))
setting = result.scalar_one_or_none()
return setting and setting.value.lower() == "true"
try:
result = await db.execute(select(Settings).where(Settings.key == "auth_enabled"))
setting = result.scalar_one_or_none()
return setting and setting.value.lower() == "true"
except Exception:
# If settings table doesn't exist or query fails, assume auth is disabled
return False
async def get_current_user_optional(
+1
View File
@@ -59,6 +59,7 @@ async def test_engine():
project,
settings,
smart_plug,
user,
)
async with engine.begin() as conn: