fix(nexus): stop magic-link login loop when localStorage is blocked#1076
Merged
Conversation
Auth tokens now persist via a safe storage fallback, hydration keeps active in-memory sessions, stale auth cookies are cleared on failed client auth, and middleware no longer bounces users off the confirm page. Closes #1075
Contributor
Author
|
@Dr0p42 — could you review this one when you have a moment? ContextFixes #1075: users hitting a magic-link login loop when browser storage is restricted. They see Confirm sign-in, click through, briefly appear signed in, then land back on Root cause (code path)
What changed
Testing
Manual check I'd appreciate your eyes on: block site storage in devtools, complete a magic-link sign-in, confirm workspace loads without looping. Thanks! |
Deploying abi-docs with
|
| Latest commit: |
dc6b884
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1160dfd9.abi-docs-76c.pages.dev |
| Branch Preview URL: | https://fix-nexus-magic-link-localst.abi-docs-76c.pages.dev |
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.
Summary
Fixes the Nexus magic-link sign-in loop reported in #1075 when the browser blocks or restricts
localStorage.localStorage->sessionStorage-> in-memory fallback).nexus-auth-flagcookies when the workspace layout detects no client token./auth/magic-linkreachable even when a stale auth cookie exists, so users can always confirm the link.Root cause
Auth relied on default
localStoragepersistence. When storage was blocked, tokens were lost after confirm, while the middleware cookie still marked the user as signed in. That bounced users between/auth/loginand/workspace/....Test plan
pnpx vitest run src/lib/safe-storage.test.ts src/lib/auth-session.test.ts src/middleware.test.ts(6 tests)next buildpassed/auth/loginno longer loops whennexus-auth-flagis set but tokens are missingCloses #1075