Repository navigation
Force full page visit when login redirects to a non-Sharp intended URL - #793
Merged
Merged
Conversation
Inertia follows redirects in XHR, so after login an intended URL pointing to an app route (e.g. one using the sharp_auth middleware) was rendered inside Sharp. Redirect with Inertia::location when the intended URL is not a code16.sharp.* route. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Login (and 2FA, passkey, impersonation) submits are Inertia XHR requests, and Inertia follows redirects. When the intended URL is an app route outside Sharp (e.g. a page protected by the
sharp_authmiddleware), the redirect response was handled as an Inertia visit instead of a real navigation.Fix
RedirectsToIntendedUrlconcern used byLoginController,LoginMultiFactorController,ImpersonateController,PasskeyAuthenticatedControllerandPasskeyRegisteredController.code16.sharp.*route, it returnsInertia::location()(409 +X-Inertia-Location) to force a full page visit; otherwise it keeps the regular redirect.Tests
Added tests in
tests/Http/Auth/AuthenticationTest.phpfor an intended Sharp URL (regular redirect) and an intended non-Sharp URL (forced full page visit).🤖 Generated with Claude Code