feat(integration): tenants by-email lookup for cross-tenant client magic-links - #188
Merged
important-new merged 1 commit intoJun 23, 2026
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_clientaccess 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
server/portal/integration.routes.tsand is M2M-guarded (requireServiceBinding).workers/app.tsreturns 404 for/api/integration/*unlessAPP_MODE === 'saas'.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