fix: harden real-portal integration after the mock-portal swap - #227
Merged
Conversation
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.
Developer
Kevin Rutledge
What changed?
The mock portal ran inside the app's own origin, so assumptions that held there broke once login and member data came from the real cross-origin portal. This PR hardens that integration. The login callback redirects with 303 so the SameSite=Lax cookie survives the cross-site POST from the portal. Every portal call gets an 8-second timeout and treats the portal's 200-on-failure responses (an INVALID_KEY sentinel, a PHP notice) as errors with a logged raw snippet. The email blast drops its 1-second per-batch sleep, which Brevo does not need, so it stays inside the function budget. Member reads are memoized per request, SMS consent refuses an empty phone, and the 1-hour session redirects to re-login and is documented as a portal constraint.
src/app/api/auth/callback/route.ts,src/app/api/auth/logout/route.ts- redirect with 303 (See Other) instead of the default 307src/lib/api/portal-api.ts- addAbortSignal.timeout(8000)to every portal call and surface the portal's 200-on-failure shapes with a raw snippetsrc/lib/api/member-api.ts- wrap the roster and member reads in Reactcache()for per-request dedupsrc/services/email.ts- drop the inter-batch delay, raiseBATCH_SIZEto 25src/services/sms-consent.ts,src/actions/settings.ts- reject SMS consent without a phone and check before persisting the togglesrc/utils/auth-redirect.ts- send a missing portal token back to sign-indocs/architecture.md,docs/decisions/auth-patterns.md- document the portal read and cache strategy, the 303 reason, and the 1-hour captest/auth,test/lib/api,test/services,test/utilsHow to test
npm testpasses (719 unit tests) andnpm run buildsucceeds.303to/homewith theprfc_authcookie set, so a cross-site portal POST lands logged in (seetest/auth/auth-flow.test.ts).Checklist