diff --git a/backend/app/core/auth.py b/backend/app/core/auth.py index 072ec5754..c30f5881b 100644 --- a/backend/app/core/auth.py +++ b/backend/app/core/auth.py @@ -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( diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index 27508ffab..8b066b982 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -59,6 +59,7 @@ async def test_engine(): project, settings, smart_plug, + user, ) async with engine.begin() as conn: