feat(vpn): regenerate wg0.conf on tenant deletion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jason Staack
2026-03-14 16:31:33 -05:00
parent 5e70890d76
commit 17d9d3e00f

View File

@@ -227,7 +227,17 @@ async def delete_tenant(
detail="Tenant not found", detail="Tenant not found",
) )
# Check if tenant had VPN configured (before cascade deletes it)
from app.services.vpn_service import get_vpn_config, sync_wireguard_config
had_vpn = await get_vpn_config(db, tenant_id)
await db.delete(tenant) await db.delete(tenant)
await db.flush()
# Regenerate wg0.conf without deleted tenant's peers
if had_vpn:
await sync_wireguard_config(db)
await db.commit() await db.commit()