Consolidate audit-fixes branch: webhooks, integrations, and deploy hardening

Batch commit of the pending working tree on security/audit-fixes-2026-07.
Major areas:
- Outbound webhooks / Zapier: schema + signed delivery with retries, public
  v1 API (REST-hook subscribe/unsubscribe), settings UI, cron drain.
- Deploy hardening: email via SMTP2GO (Resend fully removed), verified DB TLS
  (DATABASE_SSL=require + DATABASE_CA), storage fails loud in production when
  Spaces is unconfigured instead of silently using ephemeral disk.
- Integrations & features (concurrent work): accounting (QuickBooks/Xero),
  e-signature (DocuSign/Dropbox Sign), PayPal, geocoding/maps, onboarding,
  expanded legal pages.
- DB migrations 0006–0009.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Leon Serfaty
2026-07-02 13:42:34 -04:00
co-authored by Claude Opus 4.8
parent 969d5d4c8a
commit c9968531e4
282 changed files with 41530 additions and 4013 deletions
@@ -3,6 +3,7 @@ import { and, asc, eq } from "drizzle-orm"
import { db } from "@/lib/db"
import { tenants as tenantsTable, properties } from "@/lib/db/schema"
import { getSessionUser } from "@/lib/session"
import { getEffectiveOwnerId } from "@/lib/account"
import { TenantForm } from "@/components/forms/tenant-form"
import { BackButton } from "@/components/ui/back-button"
@@ -12,14 +13,16 @@ export default async function EditTenantPage({ params }: { params: Promise<{ ten
const user = await getSessionUser()
if (!user) redirect("/login")
const ownerId = await getEffectiveOwnerId(user.id)
const { tenantId } = await params
const [tenant, properties_] = await Promise.all([
db.query.tenants.findFirst({
where: and(eq(tenantsTable.id, tenantId), eq(tenantsTable.user_id, user.id)),
where: and(eq(tenantsTable.id, tenantId), eq(tenantsTable.user_id, ownerId)),
}),
db.query.properties.findMany({
where: eq(properties.user_id, user.id),
where: eq(properties.user_id, ownerId),
columns: { id: true, name: true },
with: {
units: { columns: { id: true, unit_number: true, status: true } },
+20 -10
View File
@@ -3,6 +3,7 @@ import { and, eq, desc } from "drizzle-orm"
import { db } from "@/lib/db"
import { tenants as tenantsTable, rent_payments, maintenance_requests, leases as leasesTable } from "@/lib/db/schema"
import { getSessionUser } from "@/lib/session"
import { getEffectiveOwnerId } from "@/lib/account"
import Link from "next/link"
import { formatCurrency, formatDate } from "@/lib/utils"
import { RentStatusBadge } from "@/components/dashboard/rent-status-badge"
@@ -10,15 +11,18 @@ import { MaintenanceStatusBadge, PriorityBadge } from "@/components/dashboard/ma
import { Mail, Phone } from "lucide-react"
import { CopyButton } from "@/components/shared/copy-button"
import { SendReminderButton } from "@/components/shared/send-reminder-button"
import { DeleteTenantButton } from "@/components/forms/delete-tenant-button"
export default async function TenantDetailPage({ params }: { params: Promise<{ tenantId: string }> }) {
const user = await getSessionUser()
if (!user) redirect("/login")
const ownerId = await getEffectiveOwnerId(user.id)
const { tenantId } = await params
const tenant = await db.query.tenants.findFirst({
where: and(eq(tenantsTable.id, tenantId), eq(tenantsTable.user_id, user.id)),
where: and(eq(tenantsTable.id, tenantId), eq(tenantsTable.user_id, ownerId)),
with: {
unit: { columns: { unit_number: true, rent_amount: true, bedrooms: true, bathrooms: true } },
property: { columns: { name: true, address_line1: true, city: true, state: true } },
@@ -31,19 +35,19 @@ export default async function TenantDetailPage({ params }: { params: Promise<{ t
db
.select()
.from(rent_payments)
.where(and(eq(rent_payments.user_id, user.id), eq(rent_payments.tenant_id, tenantId)))
.where(and(eq(rent_payments.user_id, ownerId), eq(rent_payments.tenant_id, tenantId)))
.orderBy(desc(rent_payments.due_date))
.limit(6),
db
.select()
.from(maintenance_requests)
.where(and(eq(maintenance_requests.user_id, user.id), eq(maintenance_requests.tenant_id, tenantId)))
.where(and(eq(maintenance_requests.user_id, ownerId), eq(maintenance_requests.tenant_id, tenantId)))
.orderBy(desc(maintenance_requests.created_at))
.limit(5),
db
.select()
.from(leasesTable)
.where(and(eq(leasesTable.user_id, user.id), eq(leasesTable.tenant_id, tenantId)))
.where(and(eq(leasesTable.user_id, ownerId), eq(leasesTable.tenant_id, tenantId)))
.orderBy(desc(leasesTable.created_at))
.limit(1),
])
@@ -74,12 +78,18 @@ export default async function TenantDetailPage({ params }: { params: Promise<{ t
</div>
</div>
</div>
<Link
href={`/tenants/${tenantId}/edit`}
className="rounded-lg border border-white/10 px-4 py-2 text-sm text-white/60 hover:border-white/20 hover:text-white transition"
>
Edit
</Link>
<div className="flex items-center gap-2">
<Link
href={`/tenants/${tenantId}/edit`}
className="rounded-lg border border-white/10 px-4 py-2 text-sm text-white/60 hover:border-white/20 hover:text-white transition"
>
Edit
</Link>
<DeleteTenantButton
tenantId={tenantId}
tenantName={`${tenant.first_name} ${tenant.last_name}`}
/>
</div>
</div>
<div className="grid gap-6 lg:grid-cols-3">
+4 -1
View File
@@ -3,6 +3,7 @@ import { asc, eq } from "drizzle-orm"
import { db } from "@/lib/db"
import { properties } from "@/lib/db/schema"
import { getSessionUser } from "@/lib/session"
import { getEffectiveOwnerId } from "@/lib/account"
import { TenantForm } from "@/components/forms/tenant-form"
import { BackButton } from "@/components/ui/back-button"
@@ -12,8 +13,10 @@ export default async function NewTenantPage() {
const user = await getSessionUser()
if (!user) redirect("/login")
const ownerId = await getEffectiveOwnerId(user.id)
const properties_ = await db.query.properties.findMany({
where: eq(properties.user_id, user.id),
where: eq(properties.user_id, ownerId),
columns: { id: true, name: true },
with: {
units: { columns: { id: true, unit_number: true, status: true } },
+4 -1
View File
@@ -3,6 +3,7 @@ import { and, eq, desc } from "drizzle-orm"
import { db } from "@/lib/db"
import { tenants as tenantsTable } from "@/lib/db/schema"
import { getSessionUser } from "@/lib/session"
import { getEffectiveOwnerId } from "@/lib/account"
import { Users, Plus } from "lucide-react"
import { EmptyState } from "@/components/shared/empty-state"
import Link from "next/link"
@@ -15,8 +16,10 @@ export default async function TenantsPage() {
const user = await getSessionUser()
if (!user) redirect("/login")
const ownerId = await getEffectiveOwnerId(user.id)
const tenants = await db.query.tenants.findMany({
where: and(eq(tenantsTable.user_id, user.id), eq(tenantsTable.status, "active")),
where: and(eq(tenantsTable.user_id, ownerId), eq(tenantsTable.status, "active")),
with: {
unit: { columns: { unit_number: true, rent_amount: true } },
property: { columns: { name: true } },
+15 -6
View File
@@ -4,6 +4,7 @@ import { useState } from "react"
import Link from "next/link"
import { Mail, Search, ArrowRight, ArrowUpDown, ArrowUp, ArrowDown } from "lucide-react"
import { formatDate, formatCurrency } from "@/lib/utils"
import { DeleteTenantButton } from "@/components/forms/delete-tenant-button"
type SortKey = "name" | "property" | "move_in" | "rent"
type SortDir = "asc" | "desc"
@@ -121,12 +122,20 @@ export function TenantsTable({ tenants }: { tenants: any[] }) {
</p>
</td>
<td className="px-5 py-4 text-right">
<Link
href={`/tenants/${tenant.id}`}
className="inline-flex items-center gap-1 text-xs text-white/30 transition group-hover:text-indigo-400"
>
View <ArrowRight className="h-3 w-3" />
</Link>
<div className="flex items-center justify-end gap-3">
<Link
href={`/tenants/${tenant.id}`}
className="inline-flex items-center gap-1 text-xs text-white/30 transition group-hover:text-indigo-400"
>
View <ArrowRight className="h-3 w-3" />
</Link>
<DeleteTenantButton
tenantId={tenant.id}
tenantName={`${tenant.first_name} ${tenant.last_name}`}
refreshOnly
compact
/>
</div>
</td>
</tr>
))}