mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 11:56:01 +02:00
Fixed auth check and conftest
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -59,6 +59,7 @@ async def test_engine():
|
||||
project,
|
||||
settings,
|
||||
smart_plug,
|
||||
user,
|
||||
)
|
||||
|
||||
async with engine.begin() as conn:
|
||||
|
||||
Reference in New Issue
Block a user