Skip to content

feat(integration): tenants by-email lookup for cross-tenant client magic-links - #188

Merged
important-new merged 1 commit into
InspectorHub:mainfrom
important-new:feat/p4-find-my-report
Jun 23, 2026
Merged

feat(integration): tenants by-email lookup for cross-tenant client magic-links#188
important-new merged 1 commit into
InspectorHub:mainfrom
important-new:feat/p4-find-my-report

Conversation

@important-new

Copy link
Copy Markdown
Contributor

What

Adds GET /api/integration/tenants/by-email?email=<email> to the SaaS integration seam (server/portal/integration.routes.ts). Returns the slugs of tenants that hold a live (revokedAt IS NULL, not expired) client/co_client access grant for the email.

Why

Enables a portal-side "find my report" entry: a homeowner enters their email once and the portal fans out to each matching tenant's existing per-tenant magic-link (POST /api/portal/:slug/request-link) — without building a cross-tenant session/data layer. Enumeration-safe (the portal always returns 200).

OSS isolation / standalone

  • SaaS-seam only — the route lives in server/portal/integration.routes.ts and is M2M-guarded (requireServiceBinding).
  • Standalone unaffected by construction: workers/app.ts returns 404 for /api/integration/* unless APP_MODE === 'saas'.
  • Reads core tables (inspection_access_tokens, tenants) read-only — no core edits, no new columns, no new core→portal import.
  • tests/portal-isolation.spec.ts (5/5) + eslint boundary remain green.

Tests

tests/unit/api/integration-tenants-by-email.spec.ts — 403 without M2M, returns only live-grant tenants (revoked excluded), 400 on missing email. 3/3 pass.

🤖 Generated with Claude Code

…gic-links (P4)

Add GET /api/integration/tenants/by-email (M2M-guarded, SaaS-seam only) returning
slugs of tenants with a live client/co_client access grant for an email. Enables a
portal-side 'find my report' fan-out without a cross-tenant session layer. Standalone
unaffected (workers/app.ts APP_MODE==='saas' 404 gate); reads core tables read-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cskv5vjBjxKNj7zeWKH2ue
@important-new
important-new merged commit bc1e80b into InspectorHub:main Jun 23, 2026
4 checks passed
@important-new
important-new deleted the feat/p4-find-my-report branch June 23, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant