feat(license): add BSL license enforcement with device limit indicator
- Add LICENSE_DEVICES env var (default 250, matches BSL 1.1 free tier) - Add /api/settings/license endpoint returning device count vs limit - Header shows flashing red "502/500 licensed" badge when over limit - About page shows license tier, device count, and over-limit warning - Nothing is crippled — all features work regardless of device count - Bump version to 9.7.1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -176,3 +176,24 @@ async def clear_winbox_sessions(user=Depends(require_role("super_admin"))):
|
||||
return {"status": "ok", "deleted": deleted}
|
||||
finally:
|
||||
await rd.aclose()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# License status (any authenticated user)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/license", summary="Get license status")
|
||||
async def get_license_status():
|
||||
"""Return current license tier, device limit, and actual device count."""
|
||||
async with AdminAsyncSessionLocal() as session:
|
||||
result = await session.execute(text("SELECT count(*)::int FROM devices"))
|
||||
device_count = result.scalar() or 0
|
||||
|
||||
limit = settings.LICENSE_DEVICES
|
||||
return {
|
||||
"licensed_devices": limit,
|
||||
"actual_devices": device_count,
|
||||
"over_limit": limit > 0 and device_count > limit,
|
||||
"tier": "commercial" if limit > 250 else "free",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user